lazysplit.dhover×1270all
/**
A compile-and-run sketch of `sparkles:ui` authoring, built **top-down** from
**expressions**: children are D lazy variadic arguments,

    Node column(ref Ui ui, NamedOnly _ = NamedOnly.init, int gap = 0, …,
        NamedOnly _children = NamedOnly.init, scope ChildFn[] children...)

so `ui.column(gap: 1, children: a, b, c)` reads like the inside-out form, but
the compiler wraps each of `a`, `b`, `c` in a delegate literal. `column` opens
its element (appended, pushed on the open stack, its env pushed), calls each
child delegate in order, then closes: the fit size is computed from the
children right there (Clay's `CloseElement`) and the env pops.

A child's identity is its parent's id mixed with its *argument position*: a
ternary with `Node.none` keeps every later sibling's position, so an `if`
never shifts identity. `mapKeyed` splices a keyed run of rows into the one
argument position it occupies; each row's id mixes in its key.

The `scope` lazy variadic must not allocate a closure in the caller. Stock
DMD 2.115 / LDC 1.43 do allocate one ("allocates closure … with the GC"), so
`@nogc` views need the frontend fix for it (dlang/dmd#22885; see README.md).

Nothing here lays out or paints. Every name is a proposal.
*/
module 
(module) lazysplit

A compile-and-run sketch of sparkles:ui authoring, built top-down from expressions*: children are D lazy variadic arguments,

Node column(ref Ui ui, NamedOnly = NamedOnly.init, int gap = 0, …, NamedOnly children = NamedOnly.init, scope ChildFn[] children...)

so ui.column(gap: 1, children: a, b, c) reads like the inside-out form, but the compiler wraps each of a, b, c in a delegate literal. column opens its element (appended, pushed on the open stack, its env pushed), calls each child delegate in order, then closes: the fit size is computed from the children right there (Clay's CloseElement) and the env pops.

A child's identity is its parent's id mixed with its argument position: a ternary with Node.none keeps every later sibling's position, so an if never shifts identity. mapKeyed splices a keyed run of rows into the one argument position it occupies; each row's id mixes in its key.

The scope lazy variadic must not allocate a closure in the caller. Stock DMD 2.115 / LDC 1.43 do allocate one ("allocates closure … with the GC"), so @nogc views need the frontend fix for it (dlang/dmd#22885; see README.md).

Nothing here lays out or paints. Every name is a proposal.

lazysplit
;
/// Where the hot layout fields live: `true` = one array per field (SoA), /// `false` = one array of `Hot` records (hot/cold split). private enum
(constant) bool lazysplit.pureSoA = false

Where the hot layout fields live: true = one array per field (SoA), false = one array of Hot records (hot/cold split).

pureSoA
= false;
import
(package) core
core
.
(module) core.interpolation

This module provides definitions to support D's interpolated expression sequence literal, sometimes called string interpolation.

string str;
int num;
// the compiler uses this module to implement the
// i"..." literal used here.
auto a = i"$​(str) has $​(num) items.";

The variable a is a sequence of expressions:

a[0] == InterpolationHeader()
a[$-1] == InterpolationFooter()

First and last, you see the header and footer, to clearly indicate where interpolation begins and ends. Note that there may be nested interpolated sequences too, each with their own header and footer. Think of them as a set of balanced parenthesis around the contents.

Inside, you will find three general categories of content: InterpolatedLiteral!"string" for string expressions, InterpolatedExpression!"code" for code expressions, and then the values themselves as their own type.

In the example:

auto a = i"$​(str) has $​(num) items.";

We will find:

a[0] == InterpolationHeader()
a[1] == InterpolatedExpression!"str"
a[2] == str
a[3] == InterpolatedLiteral!" has ";
a[4] == InterpolatedExpression!"num";
a[5] == num
a[6] == InterpolatedLiteral!" items.";
a[7] == InterpolationFooter()
a.length == 8;

You can see the correspondence with the original input: when you write $​(expression), the string of the expression is passed as InterpolatedExpression!ThatString, (excluding any parenthesis around the expression), and everything else is passed as InterpolatedLiteral!str, in the same sequence as they appeared in the source.

After an InterpolatedExpression!..., you will find the actual value(s) in the tuple. (If the expression expanded to multiple values - for example, if it was itself a tuple, there will be multiple values for a single expression.)

Library functions should NOT attempt to mixin the code from an InterpolatedExpression themselves. Doing so will fail, since it is coming from a different scope anyway. The string is provided to you only for informational purposes and as a sentinel to separate things the user wrote.

Your code should be able to handle an empty code string in InterpolatedExpression or even an entirely missing InterpolatedExpression, in case an implementation decides to not emit these.

The toString members on these return null, except for the InterpolatedLiteral, which returns the literal string. This is to ease processing by generic functions like std.stdio.write or std.conv.text, making them effectively transparently skipped.

To extract the string from an InterpolatedLiteral, you can use an is expression or the .toString method.

To extract the string from a InterpolatedExpression, you can use an is expression or the .expression member.

None of these structures have runtime state.

@historyAdded in dmd 2.10x frontend, released in late 2023.
interpolation
:
(struct) core.interpolation.InterpolationFooter

ditto

InterpolationFooter
,
(struct) core.interpolation.InterpolationHeader

Sentinel values to indicate the beginning and end of an interpolated expression sequence.

Note that these can nest, so while processing a sequence, it may be helpful to keep a nesting count if that knowledge is important to your application.

InterpolationHeader
;
import
(package) core
core
.
(module) core.lifetime
lifetime
:
(alias template) lazysplit.emplace = core.lifetime.emplace(T)(T* chunk)

Given a pointer chunk to uninitialized memory (but already typed as T), constructs an object of non-class type T at that address. If T is a class, initializes the class reference to null.

@returnsA pointer to the newly constructed object (which is the same as chunk).
emplace
;
import
(package) std
std
.
(package) std.experimental
experimental
.
(package) std.experimental.allocator
allocator
.
(package) std.experimental.allocator.building_blocks
building_blocks
.
(module) std.experimental.allocator.building_blocks.region

Source

std/experimental/allocator/building_blocks/region.d

region
:
(alias struct) lazysplit.InSituRegion = std.experimental.allocator.building_blocks.region.InSituRegion(ulong size, ulong minAlign = platformAlignment)

InSituRegion is a convenient region that carries its storage within itself (in the form of a statically-sized array).

The first template argument is the size of the region and the second is the needed alignment. Depending on the alignment requested and platform details, the actual available storage may be smaller than the compile-time parameter. To make sure that at least n bytes are available in the region, use ``InSituRegion!(n + a - 1, a).

Given that the most frequent use of InSituRegion is as a stack allocator, it allocates starting at the end on systems where stack grows downwards, such that hot memory is used first.

InSituRegion
;
import
(package) std
std
.
(module) std.traits

Templates which extract information about types and symbols at compile time.

Category Templates
Symbol Name traits fullyQualifiedName mangledName moduleName packageName
Function traits isFunction arity functionAttributes hasFunctionAttributes functionLinkage FunctionTypeOf isSafe isUnsafe isFinal ParameterDefaults ParameterIdentifierTuple ParameterStorageClassTuple Parameters ReturnType SetFunctionAttributes variadicFunctionStyle
Aggregate Type traits BaseClassesTuple BaseTypeTuple classInstanceAlignment EnumMembers FieldNameTuple Fields hasAliasing hasElaborateAssign hasElaborateCopyConstructor hasElaborateDestructor hasElaborateMove hasIndirections hasMember hasStaticMember hasNested hasUnsharedAliasing InterfacesTuple isInnerClass isNested MemberFunctionsTuple RepresentationTypeTuple TemplateArgsOf TemplateOf TransitiveBaseTypeTuple
Type Conversion CommonType AllImplicitConversionTargets ImplicitConversionTargets CopyTypeQualifiers CopyConstness isAssignable isCovariantWith isImplicitlyConvertible isQualifierConvertible
Type Constructors InoutOf ConstOf SharedOf SharedInoutOf SharedConstOf SharedConstInoutOf ImmutableOf QualifierOf
Categories of types allSameType ifTestable isType isAggregateType isArray isAssociativeArray isAutodecodableString isBasicType isBoolean isBuiltinType isCopyable isDynamicArray isEqualityComparable isFloatingPoint isIntegral isNarrowString isConvertibleToString isNumeric isOrderingComparable isPointer isScalarType isSigned isSIMDVector isSomeChar isSomeString isStaticArray isUnsigned
Type behaviours isAbstractClass isAbstractFunction isCallable isDelegate isExpressions isFinalClass isFinalFunction isFunctionPointer isInstanceOf isIterable isMutable isSomeFunction isTypeTuple
General Types ForeachType KeyType Largest mostNegative OriginalType PointerTarget Signed Unconst Unshared Unqual Unsigned ValueType Promoted
Misc lvalueOf rvalueOf Select select
User-Defined Attributes hasUDA getUDAs getSymbolsByUDA

Source

std/traits.d

@copyrightCopyright The D Language Foundation 2005 - 2009.@licenseBoost License 1.0.@authorsWalter Bright, Tomasz Stachowiak (isExpressions), Andrei Alexandrescu, Shin Fujishiro, Robert Clipsham, David Nadlinger, Kenji Hara, Shoichi Kato
traits
:
(enum) std.traits.FunctionAttribute

Returns the FunctionAttribute mask for function func.

@seehasFunctionAttributes
FunctionAttribute
,
(alias template) lazysplit.functionAttributes = std.traits.functionAttributes(alias func) if (isCallable!func)

Returns the FunctionAttribute mask for function func.

@seehasFunctionAttributes
functionAttributes
,
(alias template) lazysplit.Parameters = std.traits.Parameters(alias func) if (isCallable!func)

Get, as a tuple, the types of the parameters to a function, a pointer to function, a delegate, a struct with an opCall, a pointer to a struct with an opCall, or a class with an opCall.

Parameters
,
(alias template) lazysplit.ReturnType = std.traits.ReturnType(alias func) if (isCallable!func)

Get the type of the return value from a function, a pointer to function, a delegate, a struct with an opCall, a pointer to a struct with an opCall, or a class with an opCall. Please note that ref is not part of a type, but the attribute of the function (see template functionAttributes).

To reduce template instantiations, consider instead using typeof(() { return func(args); } ()) if the argument types are known or static if (is(typeof(func) Ret == return)) if only that basic test is needed.

ReturnType
;
import
(package) sparkles
sparkles
.
(package) sparkles.base
base
.
(module) sparkles.base.buffer

A @nogc container with Small Buffer Optimization (SBO).

Provides an append-only buffer that stores small amounts of data inline (avoiding heap allocation) and automatically switches to heap storage when capacity is exceeded.

Primary use case: appending elements in a temporary scope where GC allocation is not desired.

buffer
:
(alias struct) lazysplit.BoundedSink = sparkles.base.buffer.BoundedSink(T)

A bounded output range over storage someone else owns.

Handed out by tryWrite and valid only inside it, so a partially written destination is never observable: either the whole write fits, or nothing is kept. Overflow is recorded rather than thrown, which is what lets the entire sparkles.base.text.writers family compose inside one attempt.

BoundedSink
,
(alias template) lazysplit.HeapBuffer = sparkles.base.buffer.HeapBuffer(T, Storage extra = Storage.none) if (!(extra & ~Storage.unique))

A buffer with no inline array: the elements always live on the heap.

For a sequence whose typical size makes an inline array dead weight — the struct costs one slice regardless of how much it holds. Size it up front with reserve; there is no N to raise.

HeapBuffer
,
(alias template) lazysplit.InlineBuffer = sparkles.base.buffer.InlineBuffer(T, ulong N, Storage extra = Storage.none) if (!(extra & ~Storage.unique))

A buffer that never allocates: the elements live in the inline T[N] and nowhere else.

The policy with a guarantee no other has. Because there is no union, a slice of the storage is provably a reference to the enclosing frame, so -dip1000 rejects returning one from a @safe function — the property CString is built on. It also has no destructor, so it is plain data: copyable, comparable, and usable as a field in an aggregate that must stay POD.

It is deliberately not an output range: put promises to accept what it is given, and this cannot. Write into it with tryWrite.

Pass Storage.unique as extra for the move-only form, which is what prevents an accidental copy of a large one.

InlineBuffer
,
(enum) sparkles.base.buffer.Storage

What storage a buffer may use, and whether it may be copied.

The bits are capabilities, so the combination is the policy: inline alone never allocates, heap alone carries no inline array, and both together is the small-buffer optimization. ``Storage.none is the empty set — the neutral default for an alias's extra parameter — but a buffer with neither storage bit has nowhere to put anything and fails Buffer's constraint.

Storage
,
(alias template) lazysplit.UniqueBuffer = sparkles.base.buffer.UniqueBuffer(T, ulong N = max(size_t(1), (T[]).sizeof / T.sizeof))

Small-buffer optimization with a sole owner: inline while the elements fit, heap when they do not, and copying is disabled.

Disabling copies is what removes the reference count from the grow path — there is no second owner to consult. Hand a finished one to the shared world with toShared, which consumes it and transfers any heap block without reallocating.

UniqueBuffer
;
import
(package) sparkles
sparkles
.
(package) sparkles.base
base
.
(package) sparkles.base.pool
pool
.
(module) sparkles.base.pool.text_pool

Variable-length text behind generational ids.

TextPool generalises DqlEngine.intern (sparkles.dql.engine): text is appended to one inline byte arena and addressed by a TextSpan. The difference is that callers never hold the span. They hold an id — a Handle into a pool of spans — so the arena can reset when it empties and compact when it fragments without invalidating anything a caller kept.

The price is that text is read only inside a borrow (withText). While any borrow is open the pool does not move bytes, so the slice a callback receives stays valid for exactly as long as the callback runs.

See docs/specs/base/pool.md §5 (POOL12–POOL18, POOL22).

text_pool
:
(alias struct) lazysplit.TextPool = sparkles.base.pool.text_pool.TextPool(Tag, ulong slots, ulong bytes, ulong maxText = bytes, Reuse reuse = Reuse.lifo) if (slots > 0 && (bytes > 0) && (bytes < (uint).max) && (maxText > 0) && (maxText <= bytes))

A fixed-capacity store of up to slots texts sharing bytes bytes.

@paramTag distinguishes this pool's ids (Handle!Tag) from other handles@paramslots the most texts live at once@parambytes the arena's size, shared by all live texts@parammaxText the most bytes one text keeps; longer input is cut at a UTF-8 boundary and flagged (POOL12). Arena pressure never truncates (POOL13).@paramreuse which freed id slot is issued next
TextPool
;
import
(package) sparkles
sparkles
.
(package) sparkles.base
base
.
(package) sparkles.base.text
text
.
(module) sparkles.base.text.enums

Enum ↔ text/value conversion.

Format-agnostic primitives for an enum's two serialized forms:

  • enumMemberName — a value's member name, recased per a CaseStyle.

  • enumMemberNameOr — the same, for an enum whose members are not distinctly valued, and for a value that may not be a declared member at all.

  • enumCommonPrefix — the prefix every member name shares, so a C-derived enum can be rendered without it.

  • enumFromValue — a membership-checked underlying value back to the enum.

Enums that come from C are why the last three exist. A .h translated by ImportC routinely declares several members with the same value — an extension enumerator promoted to core keeps its old spelling as an alias — and every member repeats the type's name as a prefix, because C has no enum scope. The final switch in enumMemberName rejects the first outright (duplicate case labels), and nothing here would strip the second.

The module is unopinionated — it applies no per-member name override (that is a policy concern for a layer such as @WireName in sparkles:wired). The inverse name direction is readEnumString (sparkles.base.text.readers); the output-range writers are writeEnumMemberName / writeEnumValue (sparkles.base.text.writers).

enums
:
(alias template) lazysplit.enumMemberName = sparkles.base.text.enums.enumMemberName(CaseStyle style = CaseStyle.original, E)(in E value) if (is(E == enum))

The name of the declared member equal to value, recased per style as a compile-time string literal (so the call allocates nothing).

value must be a declared member of E. The generated final switch rejects a duplicate-valued enum at compile time (duplicate case labels) and asserts on a value that is not a declared member.

enumMemberName
;
import
(package) sparkles
sparkles
.
(package) sparkles.base
base
.
(package) sparkles.base.text
text
.
(module) sparkles.base.text.writers

@nogc-compatible text writing utilities for output ranges.

Provides functions for writing integers, floats, escaped characters/strings, and ANSI escape sequences to output ranges without GC allocation.

writers
:
(alias template) lazysplit.writeText = sparkles.base.text.writers.writeText(Writer, Args...)(ref Writer w, InterpolationHeader, Args args, InterpolationFooter)

Writes an interpolated sequence to an output range, verbatim.

SharedBuffer!(char, 128) buf;
buf.writeText(i"pid $(pid) exited with $(status)");

Plain, not styled. Literals are copied through and interpolated values go via writeValue; nothing is parsed. That is the difference from sparkles.base.styled_template.writeStyled, which reads {red …} as markup — and the reason to reach for this one whenever the text is not a style template. Interpolating a value that may contain a brace (a file path, a user's input) through the styled writer silently eats it as a style block; here a brace is a brace.

The @nogc half of the pair. std.conv.text already renders an interpolated sequence to a string, so use that where a GC allocation is fine; this is for the paths where it is not, and it inherits Writer's attributes the way every template in this module does.

writeText
;
version (
Bench
Bench
)
import
(module) benchtext

The benchmark's frame text store, used by all three builders under version (Bench): a bump arena with TextPool's intern/withText/release surface. TextPool cannot be sized for a 100 000-row frame on a test worker's 512 KiB stack: its compact keeps a uint[slots] on the stack (2 MiB at 2^19 slots), and the frame is reserved on every intern that may compact.

benchtext
:
(alias template) lazysplit.FrameBuf = benchtext.FrameBuf(T)

The frame tables' buffer in the benchmark. By default the sparkles:base HeapBuffer!(T, Storage.unique) the prototypes use; under version (RawBuf) a bare malloc'd array. The mutable Buffer.opIndex/opSlice call ensureUniqueStorage (not inlined, computing roundedCapacity) on every access even for Storage.unique, and the top-down builders index their node table far more than the inside-out one does; RawBuf takes that cost out of all three, leaving the builders' own work.

FrameBuf
;
else private alias FrameBuf(T) = HeapBuffer!(T, Storage.unique); // ── forced named arguments (docs/guidelines/idioms/forced-named-arguments) ── /// The sentinel in front of every attribute list, and again in front of /// `children`: a positional argument after the last named attribute would /// otherwise fill `children` silently. With it, `children:` is required. private struct
(struct) lazysplit.NamedOnly

The sentinel in front of every attribute list, and again in front of children: a positional argument after the last named attribute would otherwise fill children silently. With it, children: is required.

NamedOnly
{}
// ── nodes, context, text, messages ───────────────────────────────────────── /// A handle to a node this frame built. Children return it so a parent can /// tell a child built *in* its slot from one built earlier (see `evalChild`). struct
(struct) lazysplit.Node

A handle to a node this frame built. Children return it so a parent can tell a child built in its slot from one built earlier (see evalChild).

Node
{ uint
(field) uint lazysplit.Node.index
index
= uint.
(constant) uint uint.max = 4294967295u
max
;
/// An empty child: its argument position still counts, so the siblings /// after it keep their identity whether or not it is shown. enum
(struct) lazysplit.Node

A handle to a node this frame built. Children return it so a parent can tell a child built in its slot from one built earlier (see evalChild).

Node
(constant) lazysplit.Node lazysplit.Node.none = Node(4294967294u)

An empty child: its argument position still counts, so the siblings after it keep their identity whether or not it is shown.

none
=
(struct) lazysplit.Node

A handle to a node this frame built. Children return it so a parent can tell a child built in its slot from one built earlier (see evalChild).

Node
(uint.
(constant) uint uint.max = 4294967295u
max
- 1);
bool
bool lazysplit.Node.isNone() const pure nothrow @nogc @safe
isNone
() const @safe pure nothrow @nogc =>
(field) uint lazysplit.Node.index
index
==
(constant) lazysplit.Node lazysplit.Node.none = Node(4294967294u)

An empty child: its argument position still counts, so the siblings after it keep their identity whether or not it is shown.

none
.
(field) uint lazysplit.Node.index
index
;
} /// What a child slot holds: a lazy, non-capturing-by-GC subtree builder. /// `scope` at every use site is what keeps it off the GC (with the patch). alias
(alias) lazysplit.ChildFn = lazysplit.Node delegate() pure nothrow @nogc @safe

What a child slot holds: a lazy, non-capturing-by-GC subtree builder. scope at every use site is what keeps it off the GC (with the patch).

ChildFn
= Node delegate() @safe pure nothrow @nogc;
enum
(enum) lazysplit.Slot
Slot
: ubyte {
(enum value) lazysplit.Slot.code = cast(ubyte)0u
code
,
(enum value) lazysplit.Slot.heading = 1
heading
,
(enum value) lazysplit.Slot.dim = 2
dim
}
enum
(enum) lazysplit.Density
Density
: ubyte {
(enum value) lazysplit.Density.comfortable = cast(ubyte)0u
comfortable
,
(enum value) lazysplit.Density.compact = 1
compact
}
enum
(enum) lazysplit.Layout
Layout
: ubyte {
(enum value) lazysplit.Layout.wide = cast(ubyte)0u
wide
,
(enum value) lazysplit.Layout.touch = 1
touch
}
/// Context pushed by an element on open and popped on close. A child is /// evaluated after its parent opens, so it reads the context directly. struct
(struct) lazysplit.Env

Context pushed by an element on open and popped on close. A child is evaluated after its parent opens, so it reads the context directly.

Env
{
(enum) lazysplit.Layout
Layout
(field) lazysplit.Layout lazysplit.Env.layout
layout
;
(enum) lazysplit.Density
Density
(field) lazysplit.Density lazysplit.Env.density
density
;
bool
(field) bool lazysplit.Env.disabled
disabled
;
/// An override replacing `density` for a subtree.
(struct) lazysplit.EnvOverride

Context pushed by an element on open and popped on close. A child is evaluated after its parent opens, so it reads the context directly.

EnvOverride
lazysplit.EnvOverride lazysplit.Env.withDensity(lazysplit.Density d) const pure nothrow @nogc @safe

An override replacing density for a subtree.

withDensity
(
(enum) lazysplit.Density
Density
(parameter) lazysplit.Density d
d
) const @safe pure nothrow @nogc
=>
(struct) lazysplit.EnvOverride

ditto

EnvOverride
(active: true, env:
(struct) lazysplit.Env

Context pushed by an element on open and popped on close. A child is evaluated after its parent opens, so it reads the context directly.

Env
(layout:
(field) lazysplit.Layout lazysplit.Env.layout
layout
, density:
(parameter) lazysplit.Density d
d
, disabled:
(field) bool lazysplit.Env.disabled
disabled
));
} /// ditto struct
(struct) lazysplit.EnvOverride

Context pushed by an element on open and popped on close. A child is evaluated after its parent opens, so it reads the context directly.

EnvOverride
{ bool
(field) bool lazysplit.EnvOverride.active
active
;
(struct) lazysplit.Env

Context pushed by an element on open and popped on close. A child is evaluated after its parent opens, so it reads the context directly.

Env
(field) lazysplit.Env lazysplit.EnvOverride.env
env
;
} // Capacities: the demo's frame is tiny; the benchmark builds 100 000-row frames // into a heap-owned `Ui`. version (
Bench
Bench
)
{ private enum
(constant) int lazysplit.argBytes = 8388608
argBytes
= 8 << 20,
(constant) int lazysplit.maxDepth = 64
maxDepth
= 64;
} else { private enum textSlots = 512, textBytes = 4096, argBytes = 4096, maxDepth = 64; } private struct
(struct) lazysplit.FrameText
FrameText
{}
version (
Bench
Bench
)
{ import
(module) benchtext

The benchmark's frame text store, used by all three builders under version (Bench): a bump arena with TextPool's intern/withText/release surface. TextPool cannot be sized for a 100 000-row frame on a test worker's 512 KiB stack: its compact keeps a uint[slots] on the stack (2 MiB at 2^19 slots), and the frame is reserved on every intern that may compact.

benchtext
:
(struct) benchtext.BumpTextPool
BumpTextPool
;
// `TextPool` keeps a `uint[slots]` on the stack in `compact`: see `benchtext.d`. private alias
(alias) lazysplit.FrameTextPool = benchtext.BumpTextPool
FrameTextPool
=
(struct) benchtext.BumpTextPool
BumpTextPool
;
} else private alias FrameTextPool = TextPool!(FrameText, textSlots, textBytes); alias
(alias) lazysplit.TextId = benchtext.BumpTextPool.Id
TextId
=
(alias) lazysplit.FrameTextPool = benchtext.BumpTextPool
FrameTextPool
.
(struct) benchtext.BumpTextPool.Id
Id
;
/// An erased message: an index into the frame's message table. struct
(struct) lazysplit.MsgRef

An erased message: an index into the frame's message table.

MsgRef
{ uint
(field) uint lazysplit.MsgRef.index
index
= uint.
(constant) uint uint.max = 4294967295u
max
;
bool
bool lazysplit.MsgRef.isSet() const pure nothrow @nogc @safe
isSet
() const @safe pure nothrow @nogc =>
(field) uint lazysplit.MsgRef.index
index
!= uint.
(constant) uint uint.max = 4294967295u
max
;
} private ulong
ulong lazysplit.fnv(scope const(char)[] s, ulong h = 14695981039346656037LU) pure nothrow @nogc @safe
fnv
(scope const(char)[]
(parameter) const(char)[] s
s
, ulong
(parameter) ulong h
h
= 0xcbf29ce484222325) @safe pure nothrow @nogc
{ foreach (
(parameter) const(char) c
c
;
(parameter) const(char)[] s
s
)
{
(parameter) ulong h
h
^=
(local variable) const(char) c
c
;
(parameter) ulong h
h
*= 0x100000001b3;
} return
(parameter) ulong h
h
;
} private ulong
ulong lazysplit.mix(ulong a, ulong b) pure nothrow @nogc @safe
mix
(ulong
(parameter) ulong a
a
, ulong
(parameter) ulong b
b
) @safe pure nothrow @nogc
{ ulong
(local variable) ulong h
h
=
(parameter) ulong a
a
^ (
(parameter) ulong b
b
+ 0x9e3779b97f4a7c15 + (
(parameter) ulong a
a
<< 6) + (
(parameter) ulong a
a
>> 2));
(local variable) ulong h
h
^=
(local variable) ulong h
h
>> 31;
(local variable) ulong h
h
*= 0xbf58476d1ce4e5b9;
return
(local variable) ulong h
h
^ (
(local variable) ulong h
h
>> 29);
} /// A type's identity for the message check. enum ulong
(constant) ulong lazysplit.typeKey(T) = fnv(T.mangleof)

A type's identity for the message check.

typeKey
(T) = fnv(T.mangleof);
private enum uint
(constant) uint lazysplit.none = 4294967295u
none
= uint.
(constant) uint uint.max = 4294967295u
max
;
enum
(enum) lazysplit.Kind
Kind
: ubyte
{
(enum value) lazysplit.Kind.column = cast(ubyte)0u
column
,
(enum value) lazysplit.Kind.row = 1
row
,
(enum value) lazysplit.Kind.label = 2
label
,
(enum value) lazysplit.Kind.toggle = 3
toggle
,
(enum value) lazysplit.Kind.numberField = 4
numberField
,
(enum value) lazysplit.Kind.keyValue = 5
keyValue
,
(enum value) lazysplit.Kind.mapMsg = 6
mapMsg
,
(enum value) lazysplit.Kind.memo = 7
memo
} private alias
(alias) lazysplit.ApplyThunk = void function(scope const(void)* from, scope void* to) @system
ApplyThunk
= void function(scope const(void)*
(parameter) const(void)* from
from
, scope void*
(parameter) void* to
to
) @system;
private struct
(struct) lazysplit.MapRec
MapRec
{ ulong
(field) ulong lazysplit.MapRec.from
from
,
(field) ulong lazysplit.MapRec.to
to
;
(alias) lazysplit.ApplyThunk = void function(scope const(void)* from, scope void* to) @system
ApplyThunk
(field) void function(scope const(void)* from, scope void* to) @system lazysplit.MapRec.apply
apply
;
(alias) object.string = string
string
(field) string lazysplit.MapRec.fromName
fromName
,
(field) string lazysplit.MapRec.toName
toName
;
} /// One element, written once when it opens (its size and children once more /// when it closes). Children are listed, not linked: a closing element copies /// its children's indices from the children stack into the `kids` table, as /// Clay does, so no earlier record is ever updated. struct
(struct) lazysplit.NodeRec

One element, written once when it opens (its size and children once more when it closes). Children are listed, not linked: a closing element copies its children's indices from the children stack into the kids table, as Clay does, so no earlier record is ever updated.

NodeRec
{
(enum) lazysplit.Kind
Kind
(field) lazysplit.Kind lazysplit.NodeRec.kind
kind
;
// the layout fields (parent, children, gap, size, position) live in the // `Ui`'s hot tables, not here // identity: id = mix(parent id, argument position [, key]) uint
(field) uint lazysplit.NodeRec.position
position
;
bool
(field) bool lazysplit.NodeRec.keyed
keyed
;
ulong
(field) ulong lazysplit.NodeRec.key
key
;
ulong
(field) ulong lazysplit.NodeRec.id
id
;
// content
(alias) lazysplit.TextId = benchtext.BumpTextPool.Id
TextId
(field) benchtext.BumpTextPool.Id lazysplit.NodeRec.text
text
,
(field) benchtext.BumpTextPool.Id lazysplit.NodeRec.text2
text2
;
(struct) lazysplit.MsgRef

An erased message: an index into the frame's message table.

MsgRef
(field) lazysplit.MsgRef lazysplit.NodeRec.msg
msg
;
(enum) lazysplit.Slot
Slot
(field) lazysplit.Slot lazysplit.NodeRec.slot
slot
;
int
(field) int lazysplit.NodeRec.gap
gap
,
(field) int lazysplit.NodeRec.value
value
;
bool
(field) bool lazysplit.NodeRec.on
on
;
(struct) lazysplit.Env

Context pushed by an element on open and popped on close. A child is evaluated after its parent opens, so it reads the context directly.

Env
(field) lazysplit.Env lazysplit.NodeRec.env
env
; // the env this element's children see
(struct) lazysplit.MapRec
MapRec
(field) lazysplit.MapRec lazysplit.NodeRec.map
map
; // `mapMsg`
ulong
(field) ulong lazysplit.NodeRec.memoKey
memoKey
; // `memo`: hash of the arguments and the env
} private struct
(struct) lazysplit.MsgRec
MsgRec
{ ulong
(field) ulong lazysplit.MsgRec.typeKey
typeKey
;
const(void)[]
(field) const(void)[] lazysplit.MsgRec.value
value
;
(alias) lazysplit.ApplyThunk = void function(scope const(void)* from, scope void* to) @system
ApplyThunk
(field) void function(scope const(void)* from, scope void* to) @system lazysplit.MsgRec.payload
payload
;
ulong
(field) ulong lazysplit.MsgRec.payloadKey
payloadKey
;
} /// What a debug build reports instead of guessing. enum
(enum) lazysplit.DiagKind

What a debug build reports instead of guessing.

DiagKind
: ubyte
{ /// A node opened while the slot it sits in already held one: something /// was built *outside* a children slot (`auto x = ui.label(…)` in a view /// body) and took the slot meant for this node.
(enum value) lazysplit.DiagKind.slotAlreadyTaken = cast(ubyte)0u

A node opened while the slot it sits in already held one: something was built outside a children slot (auto x = ui.label(…) in a view body) and took the slot meant for this node.

slotAlreadyTaken
,
/// A child slot returned a node built before the slot was evaluated: the /// node was built eagerly, under whatever was open then, not here.
(enum value) lazysplit.DiagKind.childBuiltOutsideSlot = 1

A child slot returned a node built before the slot was evaluated: the node was built eagerly, under whatever was open then, not here.

childBuiltOutsideSlot
,
/// `ui.on` sent a message of another type than the innermost `mapMsg` /// (or the app) expects.
(enum value) lazysplit.DiagKind.messageTypeMismatch = 2

ui.on sent a message of another type than the innermost mapMsg (or the app) expects.

messageTypeMismatch
,
/// A `mapMsg` lifts into another type than its own scope expects.
(enum value) lazysplit.DiagKind.mapMsgTargetMismatch = 3

A mapMsg lifts into another type than its own scope expects.

mapMsgTargetMismatch
,
} private struct
(struct) lazysplit.Diag
Diag
{
(enum) lazysplit.DiagKind

What a debug build reports instead of guessing.

DiagKind
(field) lazysplit.DiagKind lazysplit.Diag.kind
kind
;
uint
(field) uint lazysplit.Diag.node
node
; // the node it is about
uint
(field) uint lazysplit.Diag.other
other
=
(constant) uint lazysplit.none = 4294967295u
none
; // `slotAlreadyTaken`: the node that took the slot
(alias) object.string = string
string
(field) string lazysplit.Diag.got
got
,
(field) string lazysplit.Diag.expected
expected
;
uint
(field) uint lazysplit.Diag.position
position
; // `childBuiltOutsideSlot`: the argument position
} /// An open element: where its children start on the children stack, and its /// id, kept here so a child's id never reads its parent's record. private struct
(struct) lazysplit.OpenRec

An open element: where its children start on the children stack, and its id, kept here so a child's id never reads its parent's record.

OpenRec
{ uint
(field) uint lazysplit.OpenRec.node
node
;
uint
(field) uint lazysplit.OpenRec.pendingBase
pendingBase
;
ulong
(field) ulong lazysplit.OpenRec.id
id
;
} /// The fields layout reads and writes, apart from the record (`pureSoA = false`). private struct
(struct) lazysplit.Hot

The fields layout reads and writes, apart from the record (pureSoA = false).

Hot
{ uint
(field) uint lazysplit.Hot.parent
parent
;
uint
(field) uint lazysplit.Hot.kidStart
kidStart
,
(field) uint lazysplit.Hot.childCount
childCount
;
uint
(field) uint lazysplit.Hot.w
w
,
(field) uint lazysplit.Hot.h
h
;
int
(field) int lazysplit.Hot.gap
gap
;
int
(field) int lazysplit.Hot.x
x
,
(field) int lazysplit.Hot.y
y
;
(enum) lazysplit.Kind
Kind
(field) lazysplit.Kind lazysplit.Hot.kind
kind
;
} /// A closed element waiting for its parent to close: its index and fit size, /// kept together so the parent's fit reads one contiguous run. private struct
(struct) lazysplit.Pending

A closed element waiting for its parent to close: its index and fit size, kept together so the parent's fit reads one contiguous run.

Pending
{ uint
(field) uint lazysplit.Pending.node
node
;
uint
(field) uint lazysplit.Pending.w
w
,
(field) uint lazysplit.Pending.h
h
;
} /** The frame's builder, on its owner's stack (or heap-owned for big frames) and passed `ref`. Storage as in the inside-out sketch: append-only `HeapBuffer`s for nodes and messages, a `TextPool` for text, an `InlineBuffer` scratch for `ui.text`, and an `InSituRegion` for constant messages' bytes. */ struct
(struct) lazysplit.Ui

The frame's builder, on its owner's stack (or heap-owned for big frames) and passed ref. Storage as in the inside-out sketch: append-only HeapBuffers for nodes and messages, a TextPool for text, an InlineBuffer scratch for ui.text, and an InSituRegion for constant messages' bytes.

Ui
{ private
(alias) benchtext.FrameBuf!(lazysplit.NodeRec) = sparkles.base.buffer.Buffer!(NodeRec, 0LU, cast(Storage)cast(ubyte)6u)

The frame tables' buffer in the benchmark. By default the sparkles:base HeapBuffer!(T, Storage.unique) the prototypes use; under version (RawBuf) a bare malloc'd array. The mutable Buffer.opIndex/opSlice call ensureUniqueStorage (not inlined, computing roundedCapacity) on every access even for Storage.unique, and the top-down builders index their node table far more than the inside-out one does; RawBuf takes that cost out of all three, leaving the builders' own work.

FrameBuf
!
(struct) lazysplit.NodeRec

One element, written once when it opens (its size and children once more when it closes). Children are listed, not linked: a closing element copies its children's indices from the children stack into the kids table, as Clay does, so no earlier record is ever updated.

NodeRec
(field) sparkles.base.buffer.Buffer!(NodeRec, 0LU, cast(Storage)cast(ubyte)6u) lazysplit.Ui.nodes
nodes
;
private
(alias) benchtext.FrameBuf!(lazysplit.MsgRec) = sparkles.base.buffer.Buffer!(MsgRec, 0LU, cast(Storage)cast(ubyte)6u)

The frame tables' buffer in the benchmark. By default the sparkles:base HeapBuffer!(T, Storage.unique) the prototypes use; under version (RawBuf) a bare malloc'd array. The mutable Buffer.opIndex/opSlice call ensureUniqueStorage (not inlined, computing roundedCapacity) on every access even for Storage.unique, and the top-down builders index their node table far more than the inside-out one does; RawBuf takes that cost out of all three, leaving the builders' own work.

FrameBuf
!
(struct) lazysplit.MsgRec
MsgRec
(field) sparkles.base.buffer.Buffer!(MsgRec, 0LU, cast(Storage)cast(ubyte)6u) lazysplit.Ui.msgs
msgs
;
private
(alias) benchtext.FrameBuf!(lazysplit.Diag) = sparkles.base.buffer.Buffer!(Diag, 0LU, cast(Storage)cast(ubyte)6u)

The frame tables' buffer in the benchmark. By default the sparkles:base HeapBuffer!(T, Storage.unique) the prototypes use; under version (RawBuf) a bare malloc'd array. The mutable Buffer.opIndex/opSlice call ensureUniqueStorage (not inlined, computing roundedCapacity) on every access even for Storage.unique, and the top-down builders index their node table far more than the inside-out one does; RawBuf takes that cost out of all three, leaving the builders' own work.

FrameBuf
!
(struct) lazysplit.Diag
Diag
(field) sparkles.base.buffer.Buffer!(Diag, 0LU, cast(Storage)cast(ubyte)6u) lazysplit.Ui.diags
diags
;
private
(alias) lazysplit.FrameTextPool = benchtext.BumpTextPool
FrameTextPool
(field) benchtext.BumpTextPool lazysplit.Ui.texts
texts
;
private
(alias) sparkles.base.buffer.InlineBuffer!(char, 1024LU, Storage.none) = sparkles.base.buffer.Buffer!(char, 1024LU, Storage.inline)

A buffer that never allocates: the elements live in the inline T[N] and nowhere else.

The policy with a guarantee no other has. Because there is no union, a slice of the storage is provably a reference to the enclosing frame, so -dip1000 rejects returning one from a @safe function — the property CString is built on. It also has no destructor, so it is plain data: copyable, comparable, and usable as a field in an aggregate that must stay POD.

It is deliberately not an output range: put promises to accept what it is given, and this cannot. Write into it with tryWrite.

Pass Storage.unique as extra for the move-only form, which is what prevents an accidental copy of a large one.

InlineBuffer
!(char, 1024)
(field) sparkles.base.buffer.Buffer!(char, 1024LU, Storage.inline) lazysplit.Ui.scratch
scratch
;
private
(constant) int lazysplit.argBytes = 8388608
InSituRegion
!
(constant) int lazysplit.argBytes = 8388608
argBytes
(field) std.experimental.allocator.building_blocks.region.InSituRegion!(8388608LU, 16LU) lazysplit.Ui.argArena
argArena
;
private
(struct) lazysplit.OpenRec

An open element: where its children start on the children stack, and its id, kept here so a child's id never reads its parent's record.

OpenRec
[
(constant) int lazysplit.maxDepth = 64
maxDepth
]
(field) lazysplit.OpenRec[64] lazysplit.Ui.stack
stack
; // the open elements, innermost last
private uint
(field) uint lazysplit.Ui.depth
depth
;
private
(alias) benchtext.FrameBuf!(lazysplit.Pending) = sparkles.base.buffer.Buffer!(Pending, 0LU, cast(Storage)cast(ubyte)6u)

The frame tables' buffer in the benchmark. By default the sparkles:base HeapBuffer!(T, Storage.unique) the prototypes use; under version (RawBuf) a bare malloc'd array. The mutable Buffer.opIndex/opSlice call ensureUniqueStorage (not inlined, computing roundedCapacity) on every access even for Storage.unique, and the top-down builders index their node table far more than the inside-out one does; RawBuf takes that cost out of all three, leaving the builders' own work.

FrameBuf
!
(struct) lazysplit.Pending

A closed element waiting for its parent to close: its index and fit size, kept together so the parent's fit reads one contiguous run.

Pending
(field) sparkles.base.buffer.Buffer!(Pending, 0LU, cast(Storage)cast(ubyte)6u) lazysplit.Ui.pending
pending
; // closed children of the open elements, in order
private
(alias) benchtext.FrameBuf!uint = sparkles.base.buffer.Buffer!(uint, 0LU, cast(Storage)cast(ubyte)6u)

The frame tables' buffer in the benchmark. By default the sparkles:base HeapBuffer!(T, Storage.unique) the prototypes use; under version (RawBuf) a bare malloc'd array. The mutable Buffer.opIndex/opSlice call ensureUniqueStorage (not inlined, computing roundedCapacity) on every access even for Storage.unique, and the top-down builders index their node table far more than the inside-out one does; RawBuf takes that cost out of all three, leaving the builders' own work.

FrameBuf
!uint
(field) sparkles.base.buffer.Buffer!(uint, 0LU, cast(Storage)cast(ubyte)6u) lazysplit.Ui.kids
kids
; // every element's children, contiguous per parent
static if (pureSoA) { private FrameBuf!uint hParent, hKidStart, hCount, hW, hH; private FrameBuf!int hGap, hX, hY; private FrameBuf!Kind hKind; } else private
(alias) benchtext.FrameBuf!(lazysplit.Hot) = sparkles.base.buffer.Buffer!(Hot, 0LU, cast(Storage)cast(ubyte)6u)

The frame tables' buffer in the benchmark. By default the sparkles:base HeapBuffer!(T, Storage.unique) the prototypes use; under version (RawBuf) a bare malloc'd array. The mutable Buffer.opIndex/opSlice call ensureUniqueStorage (not inlined, computing roundedCapacity) on every access even for Storage.unique, and the top-down builders index their node table far more than the inside-out one does; RawBuf takes that cost out of all three, leaving the builders' own work.

FrameBuf
!
(struct) lazysplit.Hot

The fields layout reads and writes, apart from the record (pureSoA = false).

Hot
(field) sparkles.base.buffer.Buffer!(Hot, 0LU, cast(Storage)cast(ubyte)6u) lazysplit.Ui.hot
hot
;
pragma(inline, true) private void
void lazysplit.Ui.hotAppend(uint parent, lazysplit.Kind kind, int gap, uint w, uint h) pure nothrow @nogc @safe
hotAppend
(uint
(parameter) uint parent
parent
,
(enum) lazysplit.Kind
Kind
(parameter) lazysplit.Kind kind
kind
, int
(parameter) int gap
gap
, uint
(parameter) uint w
w
, uint
(parameter) uint h
h
) @safe pure nothrow @nogc
{ static if (pureSoA) { hParent ~= parent; hKind ~= kind; hGap ~= gap; hW ~= w; hH ~= h; hKidStart ~= 0u; hCount ~= 0u; hX ~= 0; hY ~= 0; } else
(field) sparkles.base.buffer.Buffer!(Hot, 0LU, cast(Storage)cast(ubyte)6u) lazysplit.Ui.hot
hot
~=
void sparkles.base.buffer.Buffer!(lazysplit.Hot, 0LU, cast(Storage)cast(ubyte)6u).opOpAssign!"~"(lazysplit.Hot element) pure nothrow @nogc scope @safe

Appends a single element using ~= operator.

Output range interface: appends a single element.

Hot
(
void sparkles.base.buffer.Buffer!(lazysplit.Hot, 0LU, cast(Storage)cast(ubyte)6u).opOpAssign!"~"(lazysplit.Hot element) pure nothrow @nogc scope @safe

Appends a single element using ~= operator.

Output range interface: appends a single element.

parent
:
(parameter) uint parent
parent
, w:
(parameter) uint w
w
, h:
(parameter) uint h
h
, gap:
(parameter) int gap
gap
, kind:
(parameter) lazysplit.Kind kind
kind
);
} static if (pureSoA) { private uint parentOf(uint n) const @safe pure nothrow @nogc => hParent[n]; private Kind kindOf(uint n) const @safe pure nothrow @nogc => hKind[n]; private int gapOf(uint n) const @safe pure nothrow @nogc => hGap[n]; private uint wOf(uint n) const @safe pure nothrow @nogc => hW[n]; private uint hOf(uint n) const @safe pure nothrow @nogc => hH[n]; private uint countOf(uint n) const @safe pure nothrow @nogc => hCount[n]; private const(uint)[] kidsOf(uint n) const return @safe pure nothrow @nogc => kids[hKidStart[n] .. hKidStart[n] + hCount[n]]; pragma(inline, true) private void setFit(uint n, uint kidStart, uint count, uint w, uint h) @safe pure nothrow @nogc { hKidStart[n] = kidStart; hCount[n] = count; hW[n] = w; hH[n] = h; } } else { private uint
uint lazysplit.Ui.parentOf(uint n) const pure nothrow @nogc @safe
parentOf
(uint
(parameter) uint n
n
) const @safe pure nothrow @nogc =>
(field) sparkles.base.buffer.Buffer!(Hot, 0LU, cast(Storage)cast(ubyte)6u) lazysplit.Ui.hot
hot
[
(parameter) uint n
n
].
(field) uint lazysplit.Hot.parent
parent
;
private
(enum) lazysplit.Kind
Kind
lazysplit.Kind lazysplit.Ui.kindOf(uint n) const pure nothrow @nogc @safe
kindOf
(uint
(parameter) uint n
n
) const @safe pure nothrow @nogc =>
(field) sparkles.base.buffer.Buffer!(Hot, 0LU, cast(Storage)cast(ubyte)6u) lazysplit.Ui.hot
hot
[
(parameter) uint n
n
].
(field) lazysplit.Kind lazysplit.Hot.kind
kind
;
private int
int lazysplit.Ui.gapOf(uint n) const pure nothrow @nogc @safe
gapOf
(uint
(parameter) uint n
n
) const @safe pure nothrow @nogc =>
(field) sparkles.base.buffer.Buffer!(Hot, 0LU, cast(Storage)cast(ubyte)6u) lazysplit.Ui.hot
hot
[
(parameter) uint n
n
].
(field) int lazysplit.Hot.gap
gap
;
private uint
uint lazysplit.Ui.wOf(uint n) const pure nothrow @nogc @safe
wOf
(uint
(parameter) uint n
n
) const @safe pure nothrow @nogc =>
(field) sparkles.base.buffer.Buffer!(Hot, 0LU, cast(Storage)cast(ubyte)6u) lazysplit.Ui.hot
hot
[
(parameter) uint n
n
].
(field) uint lazysplit.Hot.w
w
;
private uint
uint lazysplit.Ui.hOf(uint n) const pure nothrow @nogc @safe
hOf
(uint
(parameter) uint n
n
) const @safe pure nothrow @nogc =>
(field) sparkles.base.buffer.Buffer!(Hot, 0LU, cast(Storage)cast(ubyte)6u) lazysplit.Ui.hot
hot
[
(parameter) uint n
n
].
(field) uint lazysplit.Hot.h
h
;
private uint
uint lazysplit.Ui.countOf(uint n) const pure nothrow @nogc @safe
countOf
(uint
(parameter) uint n
n
) const @safe pure nothrow @nogc =>
(field) sparkles.base.buffer.Buffer!(Hot, 0LU, cast(Storage)cast(ubyte)6u) lazysplit.Ui.hot
hot
[
(parameter) uint n
n
].
(field) uint lazysplit.Hot.childCount
childCount
;
private const(uint)[]
const(uint)[] lazysplit.Ui.kidsOf(uint n) const pure nothrow @nogc return @safe
kidsOf
(uint
(parameter) uint n
n
) const return @safe pure nothrow @nogc
=>
(field) sparkles.base.buffer.Buffer!(uint, 0LU, cast(Storage)cast(ubyte)6u) lazysplit.Ui.kids
kids
[
(field) sparkles.base.buffer.Buffer!(Hot, 0LU, cast(Storage)cast(ubyte)6u) lazysplit.Ui.hot
hot
[
(parameter) uint n
n
].
(field) uint lazysplit.Hot.kidStart
kidStart
..
(field) sparkles.base.buffer.Buffer!(Hot, 0LU, cast(Storage)cast(ubyte)6u) lazysplit.Ui.hot
hot
[
(parameter) uint n
n
].
(field) uint lazysplit.Hot.kidStart
kidStart
+
(field) sparkles.base.buffer.Buffer!(Hot, 0LU, cast(Storage)cast(ubyte)6u) lazysplit.Ui.hot
hot
[
(parameter) uint n
n
].
(field) uint lazysplit.Hot.childCount
childCount
];
pragma(inline, true) private void
void lazysplit.Ui.setFit(uint n, uint kidStart, uint count, uint w, uint h) pure nothrow @nogc @safe
setFit
(uint
(parameter) uint n
n
, uint
(parameter) uint kidStart
kidStart
, uint
(parameter) uint count
count
, uint
(parameter) uint w
w
, uint
(parameter) uint h
h
) @safe pure nothrow @nogc
{ ref
(local variable) lazysplit.Hot r
r
=
(field) sparkles.base.buffer.Buffer!(Hot, 0LU, cast(Storage)cast(ubyte)6u) lazysplit.Ui.hot
hot
[
(parameter) uint n
n
];
(local variable) lazysplit.Hot r
r
.
(field) uint lazysplit.Hot.kidStart
kidStart
=
(parameter) uint kidStart
kidStart
;
(local variable) lazysplit.Hot r
r
.
(field) uint lazysplit.Hot.childCount
childCount
=
(parameter) uint count
count
;
(local variable) lazysplit.Hot r
r
.
(field) uint lazysplit.Hot.w
w
=
(parameter) uint w
w
;
(local variable) lazysplit.Hot r
r
.
(field) uint lazysplit.Hot.h
h
=
(parameter) uint h
h
;
} } private
(struct) lazysplit.Env

Context pushed by an element on open and popped on close. A child is evaluated after its parent opens, so it reads the context directly.

Env
(field) lazysplit.Env lazysplit.Ui.currentEnv
currentEnv
;
private ulong
(field) ulong lazysplit.Ui.msgKey
msgKey
; // the message type the innermost `mapMsg` expects
private
(alias) object.string = string
string
(field) string lazysplit.Ui.msgName
msgName
;
private ulong
(field) ulong lazysplit.Ui.appMsgKey
appMsgKey
;
private
(alias) object.string = string
string
(field) string lazysplit.Ui.appMsgName
appMsgName
;
// what the slot being evaluated gives the node that opens in it private uint
(field) uint lazysplit.Ui.nextPos
nextPos
;
private bool
(field) bool lazysplit.Ui.nextKeyed
nextKeyed
;
private ulong
(field) ulong lazysplit.Ui.nextKey
nextKey
;
private bool
(field) bool lazysplit.Ui.armed
armed
; // debug: the slot is still free
private uint
(field) uint lazysplit.Ui.slotOwner
slotOwner
=
(constant) uint lazysplit.none = 4294967295u
none
; // debug: the node that took it
@disable this(this); /// Structural context, as resolved by the elements open around the caller.
(struct) lazysplit.Env

Context pushed by an element on open and popped on close. A child is evaluated after its parent opens, so it reads the context directly.

Env
lazysplit.Env lazysplit.Ui.env() const pure nothrow @nogc @safe

Structural context, as resolved by the elements open around the caller.

env
() const @safe pure nothrow @nogc =>
(field) lazysplit.Env lazysplit.Ui.currentEnv
currentEnv
;
/// The app's message type (`runApp!(view, update, Msg)` in the real host). void
void expectMsg(Msg)()

The app's message type (runApp!(view, update, Msg) in the real host).

expectMsg
(Msg)()
{ appMsgKey =
(template instance) typeKey!Msg
typeKey
!Msg;
appMsgName = Msg.stringof; } /// Formats an IES into the frame's scratch (UI-Q2.1). const(char)[]
const(char)[] text(Args...)(InterpolationHeader header, Args args, InterpolationFooter footer) return

Formats an IES into the frame's scratch (UI-Q2.1).

text
(Args...)(
(unresolved type) InterpolationHeader
InterpolationHeader
(parameter) InterpolationHeader header
header
, Args
(parameter) Args args
args
,
(unresolved type) InterpolationFooter
InterpolationFooter
(parameter) InterpolationFooter footer
footer
) return
{ const
_error_ start
start
= scratch.
scratch.length
length
;
const
_error_ fits
fits
= scratch.tryWrite((scope ref BoundedSink!char
(parameter) BoundedSink!char w
w
) {
w.
w.writeText
writeText
(header, args, footer);
}); assert(fits, "the frame's text scratch is full"); return scratch[start .. scratch.length]; } // ── the frame ────────────────────────────────────────────────────────── /// Builds the root view under `env`: the view is a lazy child, so `env` /// and the app's message type are in place before it runs.
(struct) lazysplit.Node

A handle to a node this frame built. Children return it so a parent can tell a child built in its slot from one built earlier (see evalChild).

Node
lazysplit.Node lazysplit.Ui.frame(lazysplit.Env env, lazysplit.Node delegate() pure nothrow @nogc @safe[] root...) pure nothrow @nogc @safe

Builds the root view under env: the view is a lazy child, so env and the app's message type are in place before it runs.

frame
(
(struct) lazysplit.Env

Context pushed by an element on open and popped on close. A child is evaluated after its parent opens, so it reads the context directly.

Env
(parameter) lazysplit.Env env
env
, scope
(alias) lazysplit.ChildFn = lazysplit.Node delegate() pure nothrow @nogc @safe

What a child slot holds: a lazy, non-capturing-by-GC subtree builder. scope at every use site is what keeps it off the GC (with the patch).

ChildFn
[]
(parameter) lazysplit.Node delegate() pure nothrow @nogc @safe[] root
root
...) @safe pure nothrow @nogc
{ assert(
(parameter) lazysplit.Node delegate() pure nothrow @nogc @safe[] root
root
.
(field) ulong lazysplit.Node delegate() pure nothrow @nogc @safe[].length
length
== 1, "a frame has one root view");
(field) lazysplit.Env lazysplit.Ui.currentEnv
currentEnv
=
(parameter) lazysplit.Env env
env
;
(field) ulong lazysplit.Ui.msgKey
msgKey
=
(field) ulong lazysplit.Ui.appMsgKey
appMsgKey
;
(field) string lazysplit.Ui.msgName
msgName
=
(field) string lazysplit.Ui.appMsgName
appMsgName
;
return
lazysplit.Node lazysplit.Ui.evalChild(uint pos, scope lazysplit.Node delegate() pure nothrow @nogc @safe child) pure nothrow @nogc @safe

Evaluates one child slot: the node that opens in it gets argument position pos. A debug build checks the slot is used exactly as meant.

evalChild
(0,
(parameter) lazysplit.Node delegate() pure nothrow @nogc @safe[] root
root
[0]);
} /// Drops the frame's nodes, texts and messages, keeping the storage. void
void lazysplit.Ui.reset() pure nothrow @nogc @safe

Drops the frame's nodes, texts and messages, keeping the storage.

reset
() @safe pure nothrow @nogc
{ foreach (ref
(parameter) lazysplit.NodeRec r
r
;
(field) sparkles.base.buffer.Buffer!(NodeRec, 0LU, cast(Storage)cast(ubyte)6u) lazysplit.Ui.nodes
nodes
[])
{ if (
(local variable) lazysplit.NodeRec r
r
.
(field) benchtext.BumpTextPool.Id lazysplit.NodeRec.text
text
!=
(struct) benchtext.BumpTextPool.Id
TextId
.
(constant) benchtext.BumpTextPool.Id benchtext.BumpTextPool.Id.init = Id(4294967295u, 0u)
init
)
cast(void)
(field) benchtext.BumpTextPool lazysplit.Ui.texts
texts
.
bool benchtext.BumpTextPool.release(in benchtext.BumpTextPool.Id) pure nothrow @nogc @safe
release
(
(local variable) lazysplit.NodeRec r
r
.
(field) benchtext.BumpTextPool.Id lazysplit.NodeRec.text
text
);
if (
(local variable) lazysplit.NodeRec r
r
.
(field) benchtext.BumpTextPool.Id lazysplit.NodeRec.text2
text2
!=
(struct) benchtext.BumpTextPool.Id
TextId
.
(constant) benchtext.BumpTextPool.Id benchtext.BumpTextPool.Id.init = Id(4294967295u, 0u)
init
)
cast(void)
(field) benchtext.BumpTextPool lazysplit.Ui.texts
texts
.
bool benchtext.BumpTextPool.release(in benchtext.BumpTextPool.Id) pure nothrow @nogc @safe
release
(
(local variable) lazysplit.NodeRec r
r
.
(field) benchtext.BumpTextPool.Id lazysplit.NodeRec.text2
text2
);
} static if (__traits(hasMember, texts, "clearAll"))
(field) benchtext.BumpTextPool lazysplit.Ui.texts
texts
.
void benchtext.BumpTextPool.clearAll() pure nothrow @nogc @safe
clearAll
();
(field) sparkles.base.buffer.Buffer!(NodeRec, 0LU, cast(Storage)cast(ubyte)6u) lazysplit.Ui.nodes
nodes
.
void sparkles.base.buffer.Buffer!(lazysplit.NodeRec, 0LU, cast(Storage)cast(ubyte)6u).clear(bool releaseStorage = true) pure nothrow @nogc scope @safe

Removes all elements (BUF15).

``releaseStorage: true — the default, and what a buffer whose work is finished wants — also gives the heap block back, reverting an inline policy to its inline slots. Pass false to keep the block: a builder reused across iterations then allocates once and refills, which is the whole point of having reserved it.

A policy without Storage.inline has nothing to revert to, so its block survives either way and only the destructor releases it.

Output range interface: appends a single element.

clear
(releaseStorage: false);
(field) sparkles.base.buffer.Buffer!(MsgRec, 0LU, cast(Storage)cast(ubyte)6u) lazysplit.Ui.msgs
msgs
.
void sparkles.base.buffer.Buffer!(lazysplit.MsgRec, 0LU, cast(Storage)cast(ubyte)6u).clear(bool releaseStorage = true) pure nothrow @nogc scope @safe

Removes all elements (BUF15).

``releaseStorage: true — the default, and what a buffer whose work is finished wants — also gives the heap block back, reverting an inline policy to its inline slots. Pass false to keep the block: a builder reused across iterations then allocates once and refills, which is the whole point of having reserved it.

A policy without Storage.inline has nothing to revert to, so its block survives either way and only the destructor releases it.

Output range interface: appends a single element.

clear
(releaseStorage: false);
(field) sparkles.base.buffer.Buffer!(Diag, 0LU, cast(Storage)cast(ubyte)6u) lazysplit.Ui.diags
diags
.
void sparkles.base.buffer.Buffer!(lazysplit.Diag, 0LU, cast(Storage)cast(ubyte)6u).clear(bool releaseStorage = true) pure nothrow @nogc scope @safe

Removes all elements (BUF15).

``releaseStorage: true — the default, and what a buffer whose work is finished wants — also gives the heap block back, reverting an inline policy to its inline slots. Pass false to keep the block: a builder reused across iterations then allocates once and refills, which is the whole point of having reserved it.

A policy without Storage.inline has nothing to revert to, so its block survives either way and only the destructor releases it.

Output range interface: appends a single element.

clear
(releaseStorage: false);
(field) sparkles.base.buffer.Buffer!(Pending, 0LU, cast(Storage)cast(ubyte)6u) lazysplit.Ui.pending
pending
.
void sparkles.base.buffer.Buffer!(lazysplit.Pending, 0LU, cast(Storage)cast(ubyte)6u).clear(bool releaseStorage = true) pure nothrow @nogc scope @safe

Removes all elements (BUF15).

``releaseStorage: true — the default, and what a buffer whose work is finished wants — also gives the heap block back, reverting an inline policy to its inline slots. Pass false to keep the block: a builder reused across iterations then allocates once and refills, which is the whole point of having reserved it.

A policy without Storage.inline has nothing to revert to, so its block survives either way and only the destructor releases it.

Output range interface: appends a single element.

clear
(releaseStorage: false);
static if (pureSoA) { static foreach (t; ["hParent", "hKidStart", "hCount", "hW", "hH", "hGap", "hX", "hY", "hKind"]) mixin(t ~ ".clear(releaseStorage: false);"); } else
(field) sparkles.base.buffer.Buffer!(Hot, 0LU, cast(Storage)cast(ubyte)6u) lazysplit.Ui.hot
hot
.
void sparkles.base.buffer.Buffer!(lazysplit.Hot, 0LU, cast(Storage)cast(ubyte)6u).clear(bool releaseStorage = true) pure nothrow @nogc scope @safe

Removes all elements (BUF15).

``releaseStorage: true — the default, and what a buffer whose work is finished wants — also gives the heap block back, reverting an inline policy to its inline slots. Pass false to keep the block: a builder reused across iterations then allocates once and refills, which is the whole point of having reserved it.

A policy without Storage.inline has nothing to revert to, so its block survives either way and only the destructor releases it.

Output range interface: appends a single element.

clear
(releaseStorage: false);
(field) sparkles.base.buffer.Buffer!(uint, 0LU, cast(Storage)cast(ubyte)6u) lazysplit.Ui.kids
kids
.
void sparkles.base.buffer.Buffer!(uint, 0LU, cast(Storage)cast(ubyte)6u).clear(bool releaseStorage = true) pure nothrow @nogc scope @safe

Removes all elements (BUF15).

``releaseStorage: true — the default, and what a buffer whose work is finished wants — also gives the heap block back, reverting an inline policy to its inline slots. Pass false to keep the block: a builder reused across iterations then allocates once and refills, which is the whole point of having reserved it.

A policy without Storage.inline has nothing to revert to, so its block survives either way and only the destructor releases it.

Output range interface: appends a single element.

clear
(releaseStorage: false);
(field) sparkles.base.buffer.Buffer!(char, 1024LU, Storage.inline) lazysplit.Ui.scratch
scratch
.
void sparkles.base.buffer.Buffer!(char, 1024LU, Storage.inline).clear() pure nothrow @nogc @safe

Removes all elements.

There is no storage to release — N is the whole capacity — so this is the length reset alone. It is what makes a fixed buffer rewritable: clear then Buffer.tryWrite builds a new value in pieces, where Buffer.assign takes one already assembled.

clear
();
() @trusted {
(field) std.experimental.allocator.building_blocks.region.InSituRegion!(8388608LU, 16LU) lazysplit.Ui.argArena
argArena
.
bool std.experimental.allocator.building_blocks.region.InSituRegion!(8388608LU, 16LU).deallocateAll() pure nothrow @nogc @safe

Deallocates all memory allocated with this allocator.

deallocateAll
(); }();
(field) uint lazysplit.Ui.depth
depth
= 0;
} /// The number of nodes the frame built.
(alias) object.size_t = ulong
size_t
ulong lazysplit.Ui.nodeCount() const pure nothrow @nogc @safe

The number of nodes the frame built.

nodeCount
() const @safe pure nothrow @nogc =>
(field) sparkles.base.buffer.Buffer!(NodeRec, 0LU, cast(Storage)cast(ubyte)6u) lazysplit.Ui.nodes
nodes
.
ulong sparkles.base.buffer.Buffer!(lazysplit.NodeRec, 0LU, cast(Storage)cast(ubyte)6u).length() const pure nothrow @nogc @property @safe

Returns the number of elements in the buffer.

length
;
// ── building ─────────────────────────────────────────────────────────── private
(alias) lazysplit.TextId = benchtext.BumpTextPool.Id
TextId
benchtext.BumpTextPool.Id lazysplit.Ui.intern(scope const(char)[] s) pure nothrow @nogc @safe
intern
(scope const(char)[]
(parameter) const(char)[] s
s
) @safe pure nothrow @nogc
=>
(parameter) const(char)[] s
s
.
(field) ulong const(char)[].length
length
?
(field) benchtext.BumpTextPool lazysplit.Ui.texts
texts
.
benchtext.BumpTextPool.Result benchtext.BumpTextPool.intern(scope const(char)[] s) pure nothrow @nogc @safe
intern
(
(parameter) const(char)[] s
s
).
(field) benchtext.BumpTextPool.Id benchtext.BumpTextPool.Result.value
value
:
(struct) benchtext.BumpTextPool.Id
TextId
.
(constant) benchtext.BumpTextPool.Id benchtext.BumpTextPool.Id.init = Id(4294967295u, 0u)
init
;
private uint
uint lazysplit.Ui.top() const pure nothrow @nogc @safe
top
() const @safe pure nothrow @nogc =>
(field) uint lazysplit.Ui.depth
depth
?
(field) lazysplit.OpenRec[64] lazysplit.Ui.stack
stack
[
(field) uint lazysplit.Ui.depth
depth
- 1].
(field) uint lazysplit.OpenRec.node
node
:
(constant) uint lazysplit.none = 4294967295u
none
;
/// Evaluates one child slot: the node that opens in it gets argument /// position `pos`. A debug build checks the slot is used exactly as meant. private
(struct) lazysplit.Node

A handle to a node this frame built. Children return it so a parent can tell a child built in its slot from one built earlier (see evalChild).

Node
lazysplit.Node lazysplit.Ui.evalChild(uint pos, scope lazysplit.Node delegate() pure nothrow @nogc @safe child) pure nothrow @nogc @safe

Evaluates one child slot: the node that opens in it gets argument position pos. A debug build checks the slot is used exactly as meant.

evalChild
(uint
(parameter) uint pos
pos
, scope
(alias) lazysplit.ChildFn = lazysplit.Node delegate() pure nothrow @nogc @safe

What a child slot holds: a lazy, non-capturing-by-GC subtree builder. scope at every use site is what keeps it off the GC (with the patch).

ChildFn
(parameter) lazysplit.Node delegate() pure nothrow @nogc @safe child
child
) @safe pure nothrow @nogc
{ const
(local variable) const(uint) before
before
= cast(uint)
(field) sparkles.base.buffer.Buffer!(NodeRec, 0LU, cast(Storage)cast(ubyte)6u) lazysplit.Ui.nodes
nodes
.
ulong sparkles.base.buffer.Buffer!(lazysplit.NodeRec, 0LU, cast(Storage)cast(ubyte)6u).length() const pure nothrow @nogc @property @safe

Returns the number of elements in the buffer.

length
;
(field) uint lazysplit.Ui.nextPos
nextPos
=
(parameter) uint pos
pos
;
debug { armed = true; slotOwner = none; } const
(local variable) const(lazysplit.Node) r
r
=
(parameter) lazysplit.Node delegate() pure nothrow @nogc @safe child
child
();
debug { armed = false; if (!r.isNone && r.index < before) diags ~= Diag(DiagKind.childBuiltOutsideSlot, r.index, top, position: pos); } return
(local variable) const(lazysplit.Node) r
r
;
} /// Fills in what the slot and the open elements give `rec`, appends it /// and returns its index. No other record is touched. pragma(inline, true) private uint
uint lazysplit.Ui.append(ref lazysplit.NodeRec rec, lazysplit.EnvOverride over, bool disabled, out ulong id, uint w = 0u, uint h = 0u) pure nothrow @nogc @safe

Fills in what the slot and the open elements give rec, appends it and returns its index. No other record is touched.

append
(ref
(struct) lazysplit.NodeRec

One element, written once when it opens (its size and children once more when it closes). Children are listed, not linked: a closing element copies its children's indices from the children stack into the kids table, as Clay does, so no earlier record is ever updated.

NodeRec
(parameter) lazysplit.NodeRec rec
rec
,
(struct) lazysplit.EnvOverride

Context pushed by an element on open and popped on close. A child is evaluated after its parent opens, so it reads the context directly.

EnvOverride
(parameter) lazysplit.EnvOverride over
over
, bool
(parameter) bool disabled
disabled
, out ulong
(parameter) ulong id
id
, uint
(parameter) uint w
w
= 0, uint
(parameter) uint h
h
= 0) @safe pure nothrow @nogc
{ const
(local variable) const(uint) self
self
= cast(uint)
(field) sparkles.base.buffer.Buffer!(NodeRec, 0LU, cast(Storage)cast(ubyte)6u) lazysplit.Ui.nodes
nodes
.
ulong sparkles.base.buffer.Buffer!(lazysplit.NodeRec, 0LU, cast(Storage)cast(ubyte)6u).length() const pure nothrow @nogc @property @safe

Returns the number of elements in the buffer.

length
;
debug { if (!armed) diags ~= Diag(DiagKind.slotAlreadyTaken, self, slotOwner); armed = false; slotOwner = self; }
(parameter) lazysplit.NodeRec rec
rec
.
(field) uint lazysplit.NodeRec.position
position
=
(field) uint lazysplit.Ui.nextPos
nextPos
;
(parameter) lazysplit.NodeRec rec
rec
.
(field) bool lazysplit.NodeRec.keyed
keyed
=
(field) bool lazysplit.Ui.nextKeyed
nextKeyed
;
(parameter) lazysplit.NodeRec rec
rec
.
(field) ulong lazysplit.NodeRec.key
key
=
(field) ulong lazysplit.Ui.nextKey
nextKey
;
(parameter) lazysplit.NodeRec rec
rec
.
(field) lazysplit.Env lazysplit.NodeRec.env
env
=
(parameter) lazysplit.EnvOverride over
over
.
(field) bool lazysplit.EnvOverride.active
active
?
(parameter) lazysplit.EnvOverride over
over
.
(field) lazysplit.Env lazysplit.EnvOverride.env
env
:
(field) lazysplit.Env lazysplit.Ui.currentEnv
currentEnv
;
(parameter) lazysplit.NodeRec rec
rec
.
(field) lazysplit.Env lazysplit.NodeRec.env
env
.
(field) bool lazysplit.Env.disabled
disabled
=
(parameter) lazysplit.NodeRec rec
rec
.
(field) lazysplit.Env lazysplit.NodeRec.env
env
.
(field) bool lazysplit.Env.disabled
disabled
||
(field) lazysplit.Env lazysplit.Ui.currentEnv
currentEnv
.
(field) bool lazysplit.Env.disabled
disabled
||
(parameter) bool disabled
disabled
;
ulong
(local variable) ulong parentId
parentId
;
uint
(local variable) uint parent
parent
=
(constant) uint lazysplit.none = 4294967295u
none
;
if (
(field) uint lazysplit.Ui.depth
depth
)
{
(local variable) uint parent
parent
=
(field) lazysplit.OpenRec[64] lazysplit.Ui.stack
stack
[
(field) uint lazysplit.Ui.depth
depth
- 1].
(field) uint lazysplit.OpenRec.node
node
;
(local variable) ulong parentId
parentId
=
(field) lazysplit.OpenRec[64] lazysplit.Ui.stack
stack
[
(field) uint lazysplit.Ui.depth
depth
- 1].
(field) ulong lazysplit.OpenRec.id
id
;
}
(parameter) ulong id
id
=
(parameter) lazysplit.NodeRec rec
rec
.
(field) bool lazysplit.NodeRec.keyed
keyed
?
ulong lazysplit.mix(ulong a, ulong b) pure nothrow @nogc @safe
mix
(
ulong lazysplit.mix(ulong a, ulong b) pure nothrow @nogc @safe
mix
(
(local variable) ulong parentId
parentId
,
(parameter) lazysplit.NodeRec rec
rec
.
(field) uint lazysplit.NodeRec.position
position
),
(parameter) lazysplit.NodeRec rec
rec
.
(field) ulong lazysplit.NodeRec.key
key
| 1)
:
ulong lazysplit.mix(ulong a, ulong b) pure nothrow @nogc @safe
mix
(
(local variable) ulong parentId
parentId
,
(parameter) lazysplit.NodeRec rec
rec
.
(field) uint lazysplit.NodeRec.position
position
);
(parameter) lazysplit.NodeRec rec
rec
.
(field) ulong lazysplit.NodeRec.id
id
=
(parameter) ulong id
id
;
(field) sparkles.base.buffer.Buffer!(NodeRec, 0LU, cast(Storage)cast(ubyte)6u) lazysplit.Ui.nodes
nodes
~=
void sparkles.base.buffer.Buffer!(lazysplit.NodeRec, 0LU, cast(Storage)cast(ubyte)6u).opOpAssign!"~"(lazysplit.NodeRec element) pure nothrow @nogc scope @safe

Appends a single element using ~= operator.

Output range interface: appends a single element.

rec
;
void lazysplit.Ui.hotAppend(uint parent, lazysplit.Kind kind, int gap, uint w, uint h) pure nothrow @nogc @safe
hotAppend
(
(local variable) uint parent
parent
,
(parameter) lazysplit.NodeRec rec
rec
.
(field) lazysplit.Kind lazysplit.NodeRec.kind
kind
,
(parameter) lazysplit.NodeRec rec
rec
.
(field) int lazysplit.NodeRec.gap
gap
,
(parameter) uint w
w
,
(parameter) uint h
h
);
return
(local variable) const(uint) self
self
;
} /// Opens an element: appended, pushed on the open stack. pragma(inline, true) private uint
uint lazysplit.Ui.open(lazysplit.NodeRec rec, lazysplit.EnvOverride over, bool disabled) pure nothrow @nogc @safe

Opens an element: appended, pushed on the open stack.

open
(
(struct) lazysplit.NodeRec

One element, written once when it opens (its size and children once more when it closes). Children are listed, not linked: a closing element copies its children's indices from the children stack into the kids table, as Clay does, so no earlier record is ever updated.

NodeRec
(parameter) lazysplit.NodeRec rec
rec
,
(struct) lazysplit.EnvOverride

Context pushed by an element on open and popped on close. A child is evaluated after its parent opens, so it reads the context directly.

EnvOverride
(parameter) lazysplit.EnvOverride over
over
, bool
(parameter) bool disabled
disabled
) @safe pure nothrow @nogc
{ ulong
(local variable) ulong id
id
;
const
(local variable) const(uint) self
self
=
uint lazysplit.Ui.append(ref lazysplit.NodeRec rec, lazysplit.EnvOverride over, bool disabled, out ulong id, uint w = 0u, uint h = 0u) pure nothrow @nogc @safe

Fills in what the slot and the open elements give rec, appends it and returns its index. No other record is touched.

append
(
(parameter) lazysplit.NodeRec rec
rec
,
(parameter) lazysplit.EnvOverride over
over
,
(parameter) bool disabled
disabled
,
(local variable) ulong id
id
);
assert(
(field) uint lazysplit.Ui.depth
depth
<
(field) lazysplit.OpenRec[64] lazysplit.Ui.stack
stack
.
(constant) ulong lazysplit.OpenRec[64].length = 64LU
length
, "elements nest too deep");
(field) lazysplit.OpenRec[64] lazysplit.Ui.stack
stack
[
(field) uint lazysplit.Ui.depth
depth
++] =
(struct) lazysplit.OpenRec

An open element: where its children start on the children stack, and its id, kept here so a child's id never reads its parent's record.

OpenRec
(
(local variable) const(uint) self
self
, cast(uint)
(field) sparkles.base.buffer.Buffer!(Pending, 0LU, cast(Storage)cast(ubyte)6u) lazysplit.Ui.pending
pending
.
ulong sparkles.base.buffer.Buffer!(lazysplit.Pending, 0LU, cast(Storage)cast(ubyte)6u).length() const pure nothrow @nogc @property @safe

Returns the number of elements in the buffer.

length
,
(local variable) ulong id
id
);
(field) lazysplit.Env lazysplit.Ui.currentEnv
currentEnv
=
(parameter) lazysplit.NodeRec rec
rec
.
(field) lazysplit.Env lazysplit.NodeRec.env
env
;
return
(local variable) const(uint) self
self
;
} /// Closes the innermost element: its fit size from its children's run on /// the children stack, which moves into `kids`; then it joins its own /// parent's run, and the context it pushed pops. pragma(inline, true) private void
void lazysplit.Ui.close(lazysplit.Env saved) pure nothrow @nogc @safe

Closes the innermost element: its fit size from its children's run on the children stack, which moves into kids; then it joins its own parent's run, and the context it pushed pops.

close
(
(struct) lazysplit.Env

Context pushed by an element on open and popped on close. A child is evaluated after its parent opens, so it reads the context directly.

Env
(parameter) lazysplit.Env saved
saved
) @safe pure nothrow @nogc
{ const
(local variable) const(lazysplit.OpenRec) o
o
=
(field) lazysplit.OpenRec[64] lazysplit.Ui.stack
stack
[--
(field) uint lazysplit.Ui.depth
depth
];
const
(local variable) const(lazysplit.Pending[]) run
run
=
(field) sparkles.base.buffer.Buffer!(Pending, 0LU, cast(Storage)cast(ubyte)6u) lazysplit.Ui.pending
pending
[
(local variable) const(lazysplit.OpenRec) o
o
.
(field) uint lazysplit.OpenRec.pendingBase
pendingBase
..
(field) sparkles.base.buffer.Buffer!(Pending, 0LU, cast(Storage)cast(ubyte)6u) lazysplit.Ui.pending
pending
.
ulong sparkles.base.buffer.Buffer!(lazysplit.Pending, 0LU, cast(Storage)cast(ubyte)6u).length() const pure nothrow @nogc @property @safe

Returns the number of elements in the buffer.

length
];
uint
(local variable) uint w
w
,
(local variable) uint h
h
;
if (
(local variable) const(lazysplit.Pending[]) run
run
.
(field) ulong const(lazysplit.Pending[]).length
length
)
{ const
(local variable) const(bool) horizontal
horizontal
=
lazysplit.Kind lazysplit.Ui.kindOf(uint n) const pure nothrow @nogc @safe
kindOf
(
(local variable) const(lazysplit.OpenRec) o
o
.
(field) uint lazysplit.OpenRec.node
node
) ==
(enum) lazysplit.Kind
Kind
.
(enum value) lazysplit.Kind.row = 1
row
;
uint
(local variable) uint along
along
,
(local variable) uint across
across
;
const
(local variable) const(uint) kidStart
kidStart
= cast(uint)
(field) sparkles.base.buffer.Buffer!(uint, 0LU, cast(Storage)cast(ubyte)6u) lazysplit.Ui.kids
kids
.
ulong sparkles.base.buffer.Buffer!(uint, 0LU, cast(Storage)cast(ubyte)6u).length() const pure nothrow @nogc @property @safe

Returns the number of elements in the buffer.

length
;
foreach (ref
(parameter) const(lazysplit.Pending) c
c
;
(local variable) const(lazysplit.Pending[]) run
run
)
{
(local variable) uint along
along
+=
(local variable) const(bool) horizontal
horizontal
?
(local variable) const(lazysplit.Pending) c
c
.
(field) uint lazysplit.Pending.w
w
:
(local variable) const(lazysplit.Pending) c
c
.
(field) uint lazysplit.Pending.h
h
;
const
(local variable) const(uint) a
a
=
(local variable) const(bool) horizontal
horizontal
?
(local variable) const(lazysplit.Pending) c
c
.
(field) uint lazysplit.Pending.h
h
:
(local variable) const(lazysplit.Pending) c
c
.
(field) uint lazysplit.Pending.w
w
;
if (
(local variable) const(uint) a
a
>
(local variable) uint across
across
)
(local variable) uint across
across
=
(local variable) const(uint) a
a
;
(field) sparkles.base.buffer.Buffer!(uint, 0LU, cast(Storage)cast(ubyte)6u) lazysplit.Ui.kids
kids
~=
void sparkles.base.buffer.Buffer!(uint, 0LU, cast(Storage)cast(ubyte)6u).opOpAssign!"~"(uint element) pure nothrow @nogc scope @safe

Appends a single element using ~= operator.

Output range interface: appends a single element.

c
.
void sparkles.base.buffer.Buffer!(uint, 0LU, cast(Storage)cast(ubyte)6u).opOpAssign!"~"(uint element) pure nothrow @nogc scope @safe

Appends a single element using ~= operator.

Output range interface: appends a single element.

node
;
}
(local variable) uint along
along
+=
int lazysplit.Ui.gapOf(uint n) const pure nothrow @nogc @safe
gapOf
(
(local variable) const(lazysplit.OpenRec) o
o
.
(field) uint lazysplit.OpenRec.node
node
) * cast(uint) (
(local variable) const(lazysplit.Pending[]) run
run
.
(field) ulong const(lazysplit.Pending[]).length
length
- 1);
(local variable) uint w
w
=
(local variable) const(bool) horizontal
horizontal
?
(local variable) uint along
along
:
(local variable) uint across
across
;
(local variable) uint h
h
=
(local variable) const(bool) horizontal
horizontal
?
(local variable) uint across
across
:
(local variable) uint along
along
;
void lazysplit.Ui.setFit(uint n, uint kidStart, uint count, uint w, uint h) pure nothrow @nogc @safe
setFit
(
(local variable) const(lazysplit.OpenRec) o
o
.
(field) uint lazysplit.OpenRec.node
node
,
(local variable) const(uint) kidStart
kidStart
, cast(uint)
(local variable) const(lazysplit.Pending[]) run
run
.
(field) ulong const(lazysplit.Pending[]).length
length
,
(local variable) uint w
w
,
(local variable) uint h
h
);
}
(field) sparkles.base.buffer.Buffer!(Pending, 0LU, cast(Storage)cast(ubyte)6u) lazysplit.Ui.pending
pending
.
void sparkles.base.buffer.Buffer!(lazysplit.Pending, 0LU, cast(Storage)cast(ubyte)6u).length(ulong newLength) pure nothrow @nogc @property @trusted

Sets the element count. Growing appends T.init-filled elements (one storage growth); shrinking drops elements from the back and keeps the storage, whichever it is (BUF13) — a buffer that has spilled to the heap stays there until clear or the destructor, so a shrink costs neither a copy back into the inline slots nor a free.

Output range interface: appends a single element.

length
=
(local variable) const(lazysplit.OpenRec) o
o
.
(field) uint lazysplit.OpenRec.pendingBase
pendingBase
;
(field) sparkles.base.buffer.Buffer!(Pending, 0LU, cast(Storage)cast(ubyte)6u) lazysplit.Ui.pending
pending
~=
void sparkles.base.buffer.Buffer!(lazysplit.Pending, 0LU, cast(Storage)cast(ubyte)6u).opOpAssign!"~"(lazysplit.Pending element) pure nothrow @nogc scope @safe

Appends a single element using ~= operator.

Output range interface: appends a single element.

Pending
(
(local variable) const(lazysplit.OpenRec) o
o
.
(field) uint lazysplit.OpenRec.node
node
,
(local variable) uint w
w
,
(local variable) uint h
h
);
(field) lazysplit.Env lazysplit.Ui.currentEnv
currentEnv
=
(parameter) lazysplit.Env saved
saved
;
} /// A container: open, evaluate each child slot in order, close. private
(struct) lazysplit.Node

A handle to a node this frame built. Children return it so a parent can tell a child built in its slot from one built earlier (see evalChild).

Node
lazysplit.Node lazysplit.Ui.container(lazysplit.NodeRec rec, lazysplit.EnvOverride over, bool disabled, scope lazysplit.Node delegate() pure nothrow @nogc @safe[] children) pure nothrow @nogc @safe

A container: open, evaluate each child slot in order, close.

container
(
(struct) lazysplit.NodeRec

One element, written once when it opens (its size and children once more when it closes). Children are listed, not linked: a closing element copies its children's indices from the children stack into the kids table, as Clay does, so no earlier record is ever updated.

NodeRec
(parameter) lazysplit.NodeRec rec
rec
,
(struct) lazysplit.EnvOverride

Context pushed by an element on open and popped on close. A child is evaluated after its parent opens, so it reads the context directly.

EnvOverride
(parameter) lazysplit.EnvOverride over
over
, bool
(parameter) bool disabled
disabled
,
scope
(alias) lazysplit.ChildFn = lazysplit.Node delegate() pure nothrow @nogc @safe

What a child slot holds: a lazy, non-capturing-by-GC subtree builder. scope at every use site is what keeps it off the GC (with the patch).

ChildFn
[]
(parameter) lazysplit.Node delegate() pure nothrow @nogc @safe[] children
children
) @safe pure nothrow @nogc
{ const
(local variable) const(lazysplit.Env) saved
saved
=
(field) lazysplit.Env lazysplit.Ui.currentEnv
currentEnv
;
const
(local variable) const(uint) self
self
=
uint lazysplit.Ui.open(lazysplit.NodeRec rec, lazysplit.EnvOverride over, bool disabled) pure nothrow @nogc @safe

Opens an element: appended, pushed on the open stack.

open
(
(parameter) lazysplit.NodeRec rec
rec
,
(parameter) lazysplit.EnvOverride over
over
,
(parameter) bool disabled
disabled
);
foreach (
(parameter) ulong i
i
,
(parameter) lazysplit.Node delegate() pure nothrow @nogc @safe child
child
;
(parameter) lazysplit.Node delegate() pure nothrow @nogc @safe[] children
children
)
cast(void)
lazysplit.Node lazysplit.Ui.evalChild(uint pos, scope lazysplit.Node delegate() pure nothrow @nogc @safe child) pure nothrow @nogc @safe

Evaluates one child slot: the node that opens in it gets argument position pos. A debug build checks the slot is used exactly as meant.

evalChild
(cast(uint)
(local variable) ulong i
i
,
(local variable) lazysplit.Node delegate() pure nothrow @nogc @safe child
child
);
void lazysplit.Ui.close(lazysplit.Env saved) pure nothrow @nogc @safe

Closes the innermost element: its fit size from its children's run on the children stack, which moves into kids; then it joins its own parent's run, and the context it pushed pops.

close
(
(local variable) const(lazysplit.Env) saved
saved
);
return
(struct) lazysplit.Node

A handle to a node this frame built. Children return it so a parent can tell a child built in its slot from one built earlier (see evalChild).

Node
(
(local variable) const(uint) self
self
);
} /// A leaf: open and close at once, with its own content size. pragma(inline, true) private
(struct) lazysplit.Node

A handle to a node this frame built. Children return it so a parent can tell a child built in its slot from one built earlier (see evalChild).

Node
lazysplit.Node lazysplit.Ui.leaf(lazysplit.NodeRec rec, uint w) pure nothrow @nogc @safe

A leaf: open and close at once, with its own content size.

leaf
(
(struct) lazysplit.NodeRec

One element, written once when it opens (its size and children once more when it closes). Children are listed, not linked: a closing element copies its children's indices from the children stack into the kids table, as Clay does, so no earlier record is ever updated.

NodeRec
(parameter) lazysplit.NodeRec rec
rec
, uint
(parameter) uint w
w
) @safe pure nothrow @nogc
{ const
(local variable) const(lazysplit.Env) saved
saved
=
(field) lazysplit.Env lazysplit.Ui.currentEnv
currentEnv
;
ulong
(local variable) ulong id
id
;
const
(local variable) const(uint) self
self
=
uint lazysplit.Ui.append(ref lazysplit.NodeRec rec, lazysplit.EnvOverride over, bool disabled, out ulong id, uint w = 0u, uint h = 0u) pure nothrow @nogc @safe

Fills in what the slot and the open elements give rec, appends it and returns its index. No other record is touched.

append
(
(parameter) lazysplit.NodeRec rec
rec
,
(struct) lazysplit.EnvOverride

ditto

EnvOverride
.
(constant) lazysplit.EnvOverride lazysplit.EnvOverride.init = EnvOverride(false, Env(Layout.wide, Density.comfortable, false))
init
, false,
(local variable) ulong id
id
,
(parameter) uint w
w
, 1);
(field) sparkles.base.buffer.Buffer!(Pending, 0LU, cast(Storage)cast(ubyte)6u) lazysplit.Ui.pending
pending
~=
void sparkles.base.buffer.Buffer!(lazysplit.Pending, 0LU, cast(Storage)cast(ubyte)6u).opOpAssign!"~"(lazysplit.Pending element) pure nothrow @nogc scope @safe

Appends a single element using ~= operator.

Output range interface: appends a single element.

Pending
(
(local variable) const(uint) self
self
,
(parameter) uint w
w
, 1);
return
(struct) lazysplit.Node

A handle to a node this frame built. Children return it so a parent can tell a child built in its slot from one built earlier (see evalChild).

Node
(
(local variable) const(uint) self
self
);
} private
(struct) lazysplit.MsgRef

An erased message: an index into the frame's message table.

MsgRef
lazysplit.MsgRef lazysplit.Ui.addMsg(lazysplit.MsgRec rec) pure nothrow @nogc @safe
addMsg
(
(struct) lazysplit.MsgRec
MsgRec
(parameter) lazysplit.MsgRec rec
rec
) @safe pure nothrow @nogc
{ const
(local variable) const(lazysplit.MsgRef) self
self
=
(struct) lazysplit.MsgRef

An erased message: an index into the frame's message table.

MsgRef
(cast(uint)
(field) sparkles.base.buffer.Buffer!(MsgRec, 0LU, cast(Storage)cast(ubyte)6u) lazysplit.Ui.msgs
msgs
.
ulong sparkles.base.buffer.Buffer!(lazysplit.MsgRec, 0LU, cast(Storage)cast(ubyte)6u).length() const pure nothrow @nogc @property @safe

Returns the number of elements in the buffer.

length
);
(field) sparkles.base.buffer.Buffer!(MsgRec, 0LU, cast(Storage)cast(ubyte)6u) lazysplit.Ui.msgs
msgs
~=
void sparkles.base.buffer.Buffer!(lazysplit.MsgRec, 0LU, cast(Storage)cast(ubyte)6u).opOpAssign!"~"(lazysplit.MsgRec element) pure nothrow @nogc scope @safe

Appends a single element using ~= operator.

Output range interface: appends a single element.

rec
;
return
(local variable) const(lazysplit.MsgRef) self
self
;
} /// Checks, at `ui.on` time, that `got` is what the open `mapMsg` scope /// (or the app) expects. Run time only: the enclosing scope is a runtime /// fact of the call stack, not a type the `ui` carries. private void
void lazysplit.Ui.checkMsg(ulong got, string gotName) pure nothrow @nogc @safe

Checks, at ui.on time, that got is what the open mapMsg scope (or the app) expects. Run time only: the enclosing scope is a runtime fact of the call stack, not a type the ui carries.

checkMsg
(ulong
(parameter) ulong got
got
,
(alias) object.string = string
string
(parameter) string gotName
gotName
) @safe pure nothrow @nogc
{ debug if (got != msgKey) diags ~= Diag(DiagKind.messageTypeMismatch, top, got: gotName, expected: msgName); } private const(void)[]
const(void)[] keep(T)(ref scope const T value)
keep
(T)(scope ref const T
(parameter) T value
value
)
{ const
_error_ block
block
= () @trusted {
auto
_error_ b
b
= argArena.allocate(T.sizeof);
if (b !is null) b[] = (cast(const(void)*) &value)[0 .. T.sizeof]; return b; }(); assert(block !is null, "the frame's argument arena is full"); return block; } // ── after the frame: find, dump, diagnostics, dispatch ───────────────── private bool
bool lazysplit.Ui.textIs(uint n, scope const(char)[] text) pure nothrow @nogc @safe
textIs
(uint
(parameter) uint n
n
, scope const(char)[]
(parameter) const(char)[] text
text
) @safe pure nothrow @nogc
{ bool
(local variable) bool same
same
=
(parameter) const(char)[] text
text
.
(field) ulong const(char)[].length
length
== 0;
(field) benchtext.BumpTextPool lazysplit.Ui.texts
texts
.
bool benchtext.BumpTextPool.withText!(void delegate(scope const(char)[]) pure nothrow @nogc @safe)(in benchtext.BumpTextPool.Id id, scope void delegate(scope const(char)[]) pure nothrow @nogc @safe fn) pure nothrow @nogc @safe
withText
(
(field) sparkles.base.buffer.Buffer!(NodeRec, 0LU, cast(Storage)cast(ubyte)6u) lazysplit.Ui.nodes
nodes
[
(parameter) uint n
n
].
(field) benchtext.BumpTextPool.Id lazysplit.NodeRec.text
text
, (scope const(char)[]
(parameter) const(char)[] held
held
) {
(local variable) bool same
same
=
(parameter) const(char)[] held
held
==
(parameter) const(char)[] text
text
; });
return
(local variable) bool same
same
;
} /// The first node of `kind` whose text is `text` (the demo's hit test).
(struct) lazysplit.Node

A handle to a node this frame built. Children return it so a parent can tell a child built in its slot from one built earlier (see evalChild).

Node
lazysplit.Node lazysplit.Ui.find(string kind, scope const(char)[] text, uint from = 0u) pure nothrow @nogc @safe

The first node of kind whose text is text (the demo's hit test).

find
(
(alias) object.string = string
string
(parameter) string kind
kind
, scope const(char)[]
(parameter) const(char)[] text
text
, uint
(parameter) uint from
from
= 0) @safe pure nothrow @nogc
{ foreach (
(local variable) uint i
i
;
(parameter) uint from
from
.. cast(uint)
(field) sparkles.base.buffer.Buffer!(NodeRec, 0LU, cast(Storage)cast(ubyte)6u) lazysplit.Ui.nodes
nodes
.
ulong sparkles.base.buffer.Buffer!(lazysplit.NodeRec, 0LU, cast(Storage)cast(ubyte)6u).length() const pure nothrow @nogc @property @safe

Returns the number of elements in the buffer.

length
)
if (
(field) sparkles.base.buffer.Buffer!(NodeRec, 0LU, cast(Storage)cast(ubyte)6u) lazysplit.Ui.nodes
nodes
[
(local variable) uint i
i
].
(field) lazysplit.Kind lazysplit.NodeRec.kind
kind
.
string sparkles.base.text.enums.enumMemberName!(CaseStyle.original, lazysplit.Kind)(in lazysplit.Kind value) pure nothrow @nogc @safe

The name of the declared member equal to value, recased per style as a compile-time string literal (so the call allocates nothing).

value must be a declared member of E. The generated final switch rejects a duplicate-valued enum at compile time (duplicate case labels) and asserts on a value that is not a declared member.

enumMemberName
==
(parameter) string kind
kind
&&
bool lazysplit.Ui.textIs(uint n, scope const(char)[] text) pure nothrow @nogc @safe
textIs
(
(local variable) uint i
i
,
(parameter) const(char)[] text
text
))
return
(struct) lazysplit.Node

A handle to a node this frame built. Children return it so a parent can tell a child built in its slot from one built earlier (see evalChild).

Node
(
(local variable) uint i
i
);
return
(struct) lazysplit.Node

A handle to a node this frame built. Children return it so a parent can tell a child built in its slot from one built earlier (see evalChild).

Node
.
(constant) lazysplit.Node lazysplit.Node.init = Node(4294967295u)
init
;
} /// Writes every root (normally one) and its subtree, indented: kind, /// text, fit size, id prefix, `key`, the env children see, `[msg]`. void
void dump(W)(scope W write)

Writes every root (normally one) and its subtree, indented: kind, text, fit size, id prefix, key, the env children see, [msg].

dump
(W)(scope W
(parameter) W write
write
)
{ foreach (
(parameter) i
i
; 0 .. cast(uint) nodes.
nodes.length
length
)
if (parentOf(i) == none) dumpFrom(write, i, 0); } private void
void dumpFrom(W)(scope W write, uint n, uint depth)
dumpFrom
(W)(scope W
(parameter) W write
write
, uint
(parameter) uint n
n
, uint
(parameter) uint depth
depth
)
{ const
_error_ r
r
= nodes[n];
UniqueBuffer!(char, 160)
_error_ line
line
;
line.
line.writeText
writeText
(i"$(r.kind.enumMemberName)");
texts.
texts.withText
withText
(r.
r.text
text
, (scope const(char)[]
(parameter) const(char)[] text
text
) { line.
line.writeText
writeText
(i` "$(text)"`); });
line.
line.writeText
writeText
(i" $(wOf(n))×$(hOf(n)) @$(r.position) #$(hex4(r.id))");
if (r.
r.keyed
keyed
)
line.
line.writeText
writeText
(i" key");
if (r.
r.kind
kind
== Kind.
Kind.column
column
|| r.
r.kind
kind
== Kind.
Kind.row
row
|| r.
r.kind
kind
== Kind.
Kind.mapMsg
mapMsg
|| r.
r.kind
kind
== Kind.
Kind.memo
memo
)
line.
line.writeText
writeText
(i" [$(r.env.density.enumMemberName)]");
if (r.
r.env
env
.
r.env.disabled
disabled
)
line.
line.writeText
writeText
(i" disabled");
if (r.
r.kind
kind
== Kind.
Kind.memo
memo
)
line.
line.writeText
writeText
(i" memoKey #$(hex4(r.memoKey))");
if (r.
r.msg
msg
.
r.msg.isSet
isSet
)
line.
line.writeText
writeText
(i" [msg]");
write(depth, line[].idup); foreach (
(parameter) c
c
; kidsOf(n))
dumpFrom(write, c, depth + 1); } /// The 16-bit id prefix `dump` shows. char[4]
char[4] lazysplit.Ui.shortId(lazysplit.Node n) const pure nothrow @nogc @safe

The 16-bit id prefix dump shows.

shortId
(
(struct) lazysplit.Node

A handle to a node this frame built. Children return it so a parent can tell a child built in its slot from one built earlier (see evalChild).

Node
(parameter) lazysplit.Node n
n
) const @safe pure nothrow @nogc =>
char[4] lazysplit.hex4(ulong v) pure nothrow @nogc @safe
hex4
(
(field) sparkles.base.buffer.Buffer!(NodeRec, 0LU, cast(Storage)cast(ubyte)6u) lazysplit.Ui.nodes
nodes
[
(parameter) lazysplit.Node n
n
.
(field) uint lazysplit.Node.index
index
].
(field) ulong lazysplit.NodeRec.id
id
);
/// Whether the frame recorded no message-type diagnostic. bool
bool lazysplit.Ui.messagesTypeCheck() const pure nothrow @nogc @safe

Whether the frame recorded no message-type diagnostic.

messagesTypeCheck
() const @safe pure nothrow @nogc
{ foreach (
(parameter) const(lazysplit.Diag) d
d
;
(field) sparkles.base.buffer.Buffer!(Diag, 0LU, cast(Storage)cast(ubyte)6u) lazysplit.Ui.diags
diags
[])
if (
(local variable) const(lazysplit.Diag) d
d
.
(field) lazysplit.DiagKind lazysplit.Diag.kind
kind
==
(enum) lazysplit.DiagKind

What a debug build reports instead of guessing.

DiagKind
.
(enum value) lazysplit.DiagKind.messageTypeMismatch = 2

ui.on sent a message of another type than the innermost mapMsg (or the app) expects.

messageTypeMismatch
||
(local variable) const(lazysplit.Diag) d
d
.
(field) lazysplit.DiagKind lazysplit.Diag.kind
kind
==
(enum) lazysplit.DiagKind

What a debug build reports instead of guessing.

DiagKind
.
(enum value) lazysplit.DiagKind.mapMsgTargetMismatch = 3

A mapMsg lifts into another type than its own scope expects.

mapMsgTargetMismatch
)
return false; return true; } private void
void lazysplit.Ui.describe(ref sparkles.base.buffer.Buffer!(char, 240LU, cast(Storage)cast(ubyte)7u) line, uint n)
describe
(ref
(alias) sparkles.base.buffer.UniqueBuffer!(char, 240LU) = sparkles.base.buffer.Buffer!(char, 240LU, cast(Storage)cast(ubyte)7u)

Small-buffer optimization with a sole owner: inline while the elements fit, heap when they do not, and copying is disabled.

Disabling copies is what removes the reference count from the grow path — there is no second owner to consult. Hand a finished one to the shared world with toShared, which consumes it and transfers any heap block without reallocating.

UniqueBuffer
!(char, 240)
(parameter) sparkles.base.buffer.Buffer!(char, 240LU, cast(Storage)cast(ubyte)7u) line
line
, uint
(parameter) uint n
n
)
{ const
(local variable) const(lazysplit.NodeRec) r
r
=
(field) sparkles.base.buffer.Buffer!(NodeRec, 0LU, cast(Storage)cast(ubyte)6u) lazysplit.Ui.nodes
nodes
[
(parameter) uint n
n
];
(parameter) sparkles.base.buffer.Buffer!(char, 240LU, cast(Storage)cast(ubyte)7u) line
line
.
void sparkles.base.text.writers.writeText!(sparkles.base.buffer.Buffer!(char, 240LU, cast(Storage)cast(ubyte)7u), core.interpolation.InterpolatedExpression!"r.kind.enumMemberName", string)(ref sparkles.base.buffer.Buffer!(char, 240LU, cast(Storage)cast(ubyte)7u) w, core.interpolation.InterpolationHeader __param_1, core.interpolation.InterpolatedExpression!"r.kind.enumMemberName" __param_2, string __param_3, core.interpolation.InterpolationFooter __param_4) pure nothrow @nogc @safe

Writes an interpolated sequence to an output range, verbatim.

SharedBuffer!(char, 128) buf;
buf.writeText(i"pid $(pid) exited with $(status)");

Plain, not styled. Literals are copied through and interpolated values go via writeValue; nothing is parsed. That is the difference from sparkles.base.styled_template.writeStyled, which reads {red …} as markup — and the reason to reach for this one whenever the text is not a style template. Interpolating a value that may contain a brace (a file path, a user's input) through the styled writer silently eats it as a style block; here a brace is a brace.

The @nogc half of the pair. std.conv.text already renders an interpolated sequence to a string, so use that where a GC allocation is fine; this is for the paths where it is not, and it inherits Writer's attributes the way every template in this module does.

Examples

SharedBuffer!(char, 64) buf;
const pid = 1234;
buf.writeText(i"/proc/$(pid)/status");
assert(buf[] == "/proc/1234/status");
writeText
(
(template instance) core.interpolation.InterpolatedExpression!"r.kind.enumMemberName"
i
"$(r.kind.enumMemberName)");
(field) benchtext.BumpTextPool lazysplit.Ui.texts
texts
.
bool benchtext.BumpTextPool.withText!(void delegate(scope const(char)[]) pure nothrow @nogc @safe)(in benchtext.BumpTextPool.Id id, scope void delegate(scope const(char)[]) pure nothrow @nogc @safe fn) pure nothrow @nogc @safe
withText
(
(local variable) const(lazysplit.NodeRec) r
r
.
(field) benchtext.BumpTextPool.Id lazysplit.NodeRec.text
text
, (scope const(char)[]
(parameter) const(char)[] text
text
) {
(parameter) sparkles.base.buffer.Buffer!(char, 240LU, cast(Storage)cast(ubyte)7u) line
line
.
void sparkles.base.text.writers.writeText!(sparkles.base.buffer.Buffer!(char, 240LU, cast(Storage)cast(ubyte)7u), core.interpolation.InterpolatedLiteral!" \"", core.interpolation.InterpolatedExpression!"text", const(char)[], core.interpolation.InterpolatedLiteral!"\"")(ref sparkles.base.buffer.Buffer!(char, 240LU, cast(Storage)cast(ubyte)7u) w, core.interpolation.InterpolationHeader __param_1, core.interpolation.InterpolatedLiteral!" \"" __param_2, core.interpolation.InterpolatedExpression!"text" __param_3, const(char)[] __param_4, core.interpolation.InterpolatedLiteral!"\"" __param_5, core.interpolation.InterpolationFooter __param_6) pure nothrow @nogc @safe

Writes an interpolated sequence to an output range, verbatim.

SharedBuffer!(char, 128) buf;
buf.writeText(i"pid $(pid) exited with $(status)");

Plain, not styled. Literals are copied through and interpolated values go via writeValue; nothing is parsed. That is the difference from sparkles.base.styled_template.writeStyled, which reads {red …} as markup — and the reason to reach for this one whenever the text is not a style template. Interpolating a value that may contain a brace (a file path, a user's input) through the styled writer silently eats it as a style block; here a brace is a brace.

The @nogc half of the pair. std.conv.text already renders an interpolated sequence to a string, so use that where a GC allocation is fine; this is for the paths where it is not, and it inherits Writer's attributes the way every template in this module does.

Examples

SharedBuffer!(char, 64) buf;
const pid = 1234;
buf.writeText(i"/proc/$(pid)/status");
assert(buf[] == "/proc/1234/status");
writeText
(
(template instance) core.interpolation.InterpolatedLiteral!" \""
i
` "$(text)"`); });
(parameter) sparkles.base.buffer.Buffer!(char, 240LU, cast(Storage)cast(ubyte)7u) line
line
.
void sparkles.base.text.writers.writeText!(sparkles.base.buffer.Buffer!(char, 240LU, cast(Storage)cast(ubyte)7u), core.interpolation.InterpolatedLiteral!" #", core.interpolation.InterpolatedExpression!"hex4(r.id)", char[4])(ref sparkles.base.buffer.Buffer!(char, 240LU, cast(Storage)cast(ubyte)7u) w, core.interpolation.InterpolationHeader __param_1, core.interpolation.InterpolatedLiteral!" #" __param_2, core.interpolation.InterpolatedExpression!"hex4(r.id)" __param_3, char[4] __param_4, core.interpolation.InterpolationFooter __param_5) pure nothrow @nogc @safe

Writes an interpolated sequence to an output range, verbatim.

SharedBuffer!(char, 128) buf;
buf.writeText(i"pid $(pid) exited with $(status)");

Plain, not styled. Literals are copied through and interpolated values go via writeValue; nothing is parsed. That is the difference from sparkles.base.styled_template.writeStyled, which reads {red …} as markup — and the reason to reach for this one whenever the text is not a style template. Interpolating a value that may contain a brace (a file path, a user's input) through the styled writer silently eats it as a style block; here a brace is a brace.

The @nogc half of the pair. std.conv.text already renders an interpolated sequence to a string, so use that where a GC allocation is fine; this is for the paths where it is not, and it inherits Writer's attributes the way every template in this module does.

Examples

SharedBuffer!(char, 64) buf;
const pid = 1234;
buf.writeText(i"/proc/$(pid)/status");
assert(buf[] == "/proc/1234/status");
writeText
(
(template instance) core.interpolation.InterpolatedLiteral!" #"
i
" #$(hex4(r.id))");
} /// Reports every diagnostic of the frame (debug builds only record them). void
void diagnostics(W)(scope W write)

Reports every diagnostic of the frame (debug builds only record them).

diagnostics
(W)(scope W
(parameter) W write
write
)
{ foreach (
(parameter) d
d
; diags[])
{ UniqueBuffer!(char, 240)
_error_ line
line
;
line.
line.writeText
writeText
(i"$(d.kind.enumMemberName): ");
describe(line, d.
d.node
node
);
final switch (d.
d.kind
kind
)
{ case DiagKind.
DiagKind.slotAlreadyTaken
slotAlreadyTaken
:
line.
line.writeText
writeText
(i" opened in a slot already taken by ");
if (d.
d.other
other
== none)
line.
line.writeText
writeText
(i"a node");
else describe(line, d.
d.other
other
);
line.
line.writeText
writeText
(i", built outside a children slot");
break; case DiagKind.
DiagKind.childBuiltOutsideSlot
childBuiltOutsideSlot
:
line.
line.writeText
writeText
(i" was passed as child @$(d.position) of ");
if (d.
d.other
other
== none)
line.
line.writeText
writeText
(i"the frame");
else describe(line, d.
d.other
other
);
line.
line.writeText
writeText
(i" but built before it opened");
break; case DiagKind.
DiagKind.messageTypeMismatch
messageTypeMismatch
:
case DiagKind.
DiagKind.mapMsgTargetMismatch
mapMsgTargetMismatch
:
line.
line.writeText
writeText
(i" sends $(d.got) where $(d.expected) is expected");
break; } write(line[].idup); } } /** Delivers the message `target` sends, as the app's `Msg`: decoded, then mapped by every `mapMsg` between `target` and the root. */ void
void dispatch(Msg)(Node target, scope void delegate(Msg) @safe deliver, int payload = 0)

Delivers the message target sends, as the app's Msg: decoded, then mapped by every mapMsg between target and the root.

dispatch
(Msg)(
(unresolved type) Node
Node
(parameter) Node target
target
, scope void delegate(Msg) @safe
(parameter) void delegate(Msg) @safe deliver
deliver
, int
(parameter) int payload
payload
= 0)
{ align(16) ubyte[256]
_error_ a
a
,
_error_ b
b
;
const
_error_ m
m
= msgs[nodes[target.
target.index
index
].
nodes[target.index].msg
msg
.
nodes[target.index].msg.index
index
];
ulong
_error_ key
key
= m.
m.typeKey
typeKey
;
if (m.
m.payload
payload
!is null)
{ assert(m.
m.payloadKey
payloadKey
==
(template instance) typeKey!int
typeKey
!int, "the payload is not an `int`");
(() @trusted => m.
m.payload
payload
(&payload, &a[0]))();
} else a[0 .. m.value.length] = cast(const(ubyte)[]) m.
m.value
value
;
for (uint
_error_ n
n
= parentOf(target.
target.index
index
); n != none; n = parentOf(n))
if (nodes[n].
nodes[n].kind
kind
== Kind.
Kind.mapMsg
mapMsg
)
{ assert(nodes[n].
nodes[n].map
map
.
nodes[n].map.from
from
== key, "a message reached a mapMsg of another type");
(() @trusted => nodes[n].
nodes[n].map
map
.
nodes[n].map.apply
apply
(&a[0], &b[0]))();
a = b; key = nodes[n].
nodes[n].map
map
.
nodes[n].map.to
to
;
} assert(key ==
(template instance) typeKey!Msg
typeKey
!Msg, "the message is not the app's Msg");
deliver((() @trusted => *cast(Msg*) &a[0])()); } // ── a layout pass after the build: positions, top-down ───────────────── /// Positions every element from the fit sizes: a child sits at its /// parent's position plus the extent of its earlier siblings and gaps. /// One sweep in node order (parents precede their children). void
void lazysplit.Ui.place() pure nothrow @nogc @safe

Positions every element from the fit sizes: a child sits at its parent's position plus the extent of its earlier siblings and gaps. One sweep in node order (parents precede their children).

place
() @safe pure nothrow @nogc
{ const
(local variable) const(uint) n
n
= cast(uint)
(field) sparkles.base.buffer.Buffer!(NodeRec, 0LU, cast(Storage)cast(ubyte)6u) lazysplit.Ui.nodes
nodes
.
ulong sparkles.base.buffer.Buffer!(lazysplit.NodeRec, 0LU, cast(Storage)cast(ubyte)6u).length() const pure nothrow @nogc @property @safe

Returns the number of elements in the buffer.

length
;
if (
(local variable) const(uint) n
n
== 0)
return; static if (pureSoA) { auto xs = hX[], ys = hY[]; const ws = hW[], hs = hH[], gaps = hGap[], counts = hCount[], starts = hKidStart[]; const kinds = hKind[]; const ks = kids[]; xs[0] = 0; ys[0] = 0; foreach (i; 0 .. n) { if (counts[i] == 0) continue; const horizontal = kinds[i] == Kind.row; int x = xs[i], y = ys[i]; const g = gaps[i]; foreach (c; ks[starts[i] .. starts[i] + counts[i]]) { xs[c] = x; ys[c] = y; if (horizontal) x += ws[c] + g; else y += hs[c] + g; } } } else { auto
(local variable) lazysplit.Hot[] t
t
=
(field) sparkles.base.buffer.Buffer!(Hot, 0LU, cast(Storage)cast(ubyte)6u) lazysplit.Ui.hot
hot
[];
const
(local variable) const(uint[]) ks
ks
=
(field) sparkles.base.buffer.Buffer!(uint, 0LU, cast(Storage)cast(ubyte)6u) lazysplit.Ui.kids
kids
[];
(local variable) lazysplit.Hot[] t
t
[0].
(field) int lazysplit.Hot.x
x
= 0;
(local variable) lazysplit.Hot[] t
t
[0].
(field) int lazysplit.Hot.y
y
= 0;
foreach (
(local variable) uint i
i
; 0 ..
(local variable) const(uint) n
n
)
{ const
(local variable) const(lazysplit.Hot) p
p
=
(local variable) lazysplit.Hot[] t
t
[
(local variable) uint i
i
];
if (
(local variable) const(lazysplit.Hot) p
p
.
(field) uint lazysplit.Hot.childCount
childCount
== 0)
continue; const
(local variable) const(bool) horizontal
horizontal
=
(local variable) const(lazysplit.Hot) p
p
.
(field) lazysplit.Kind lazysplit.Hot.kind
kind
==
(enum) lazysplit.Kind
Kind
.
(enum value) lazysplit.Kind.row = 1
row
;
int
(local variable) int x
x
=
(local variable) const(lazysplit.Hot) p
p
.
(field) int lazysplit.Hot.x
x
,
(local variable) int y
y
=
(local variable) const(lazysplit.Hot) p
p
.
(field) int lazysplit.Hot.y
y
;
foreach (
(parameter) const(uint) c
c
;
(local variable) const(uint[]) ks
ks
[
(local variable) const(lazysplit.Hot) p
p
.
(field) uint lazysplit.Hot.kidStart
kidStart
..
(local variable) const(lazysplit.Hot) p
p
.
(field) uint lazysplit.Hot.kidStart
kidStart
+
(local variable) const(lazysplit.Hot) p
p
.
(field) uint lazysplit.Hot.childCount
childCount
])
{ ref
(local variable) lazysplit.Hot k
k
=
(local variable) lazysplit.Hot[] t
t
[
(local variable) const(uint) c
c
];
(local variable) lazysplit.Hot k
k
.
(field) int lazysplit.Hot.x
x
=
(local variable) int x
x
;
(local variable) lazysplit.Hot k
k
.
(field) int lazysplit.Hot.y
y
=
(local variable) int y
y
;
if (
(local variable) const(bool) horizontal
horizontal
)
(local variable) int x
x
+=
(local variable) lazysplit.Hot k
k
.
(field) uint lazysplit.Hot.w
w
+
(local variable) const(lazysplit.Hot) p
p
.
(field) int lazysplit.Hot.gap
gap
;
else
(local variable) int y
y
+=
(local variable) lazysplit.Hot k
k
.
(field) uint lazysplit.Hot.h
h
+
(local variable) const(lazysplit.Hot) p
p
.
(field) int lazysplit.Hot.gap
gap
;
} } } } /// A checksum of every element's position. ulong
ulong lazysplit.Ui.positionsHash() const pure nothrow @nogc @safe

A checksum of every element's position.

positionsHash
() const @safe pure nothrow @nogc
{ ulong
(local variable) ulong h
h
= 1469598103934665603UL;
foreach (
(local variable) uint i
i
; 0 .. cast(uint)
(field) sparkles.base.buffer.Buffer!(NodeRec, 0LU, cast(Storage)cast(ubyte)6u) lazysplit.Ui.nodes
nodes
.
ulong sparkles.base.buffer.Buffer!(lazysplit.NodeRec, 0LU, cast(Storage)cast(ubyte)6u).length() const pure nothrow @nogc @property @safe

Returns the number of elements in the buffer.

length
)
{ static if (pureSoA) const x = hX[i], y = hY[i]; else const
(local variable) const(int) x
x
=
(field) sparkles.base.buffer.Buffer!(Hot, 0LU, cast(Storage)cast(ubyte)6u) lazysplit.Ui.hot
hot
[
(local variable) uint i
i
].
(field) int lazysplit.Hot.x
x
,
(local variable) const(int) y
y
=
(field) sparkles.base.buffer.Buffer!(Hot, 0LU, cast(Storage)cast(ubyte)6u) lazysplit.Ui.hot
hot
[
(local variable) uint i
i
].
(field) int lazysplit.Hot.y
y
;
(local variable) ulong h
h
= (
(local variable) ulong h
h
^ (cast(ulong) cast(uint)
(local variable) const(int) x
x
<< 32 | cast(uint)
(local variable) const(int) y
y
)) * 1099511628211UL;
} return
(local variable) ulong h
h
;
} // ── read-only access for the benchmark's tree checksum ───────────────── const(
(struct) lazysplit.NodeRec

One element, written once when it opens (its size and children once more when it closes). Children are listed, not linked: a closing element copies its children's indices from the children stack into the kids table, as Clay does, so no earlier record is ever updated.

NodeRec
)[]
const(lazysplit.NodeRec)[] lazysplit.Ui.records() const pure nothrow @nogc return @safe
records
() const return @safe pure nothrow @nogc =>
(field) sparkles.base.buffer.Buffer!(NodeRec, 0LU, cast(Storage)cast(ubyte)6u) lazysplit.Ui.nodes
nodes
[];
/// Pre-order checksum of the tree under `n`. void
void lazysplit.Ui.checksum(lazysplit.Node n, ref ulong h, ref ulong count) const pure nothrow @nogc @safe

Pre-order checksum of the tree under n.

checksum
(
(struct) lazysplit.Node

A handle to a node this frame built. Children return it so a parent can tell a child built in its slot from one built earlier (see evalChild).

Node
(parameter) lazysplit.Node n
n
, ref ulong
(parameter) ulong h
h
, ref
(alias) object.size_t = ulong
size_t
(parameter) ulong count
count
) const @safe pure nothrow @nogc
{ import
(module) treehash

The tree checksum every builder folds its nodes into, in pre-order.

treehash
:
(alias) treeHash = ulong treehash.treeHash(ulong h, scope const(char)[] kind, uint w, uint hgt, uint children) pure nothrow @nogc @safe
treeHash
;
const
(local variable) const(lazysplit.NodeRec) r
r
=
(field) sparkles.base.buffer.Buffer!(NodeRec, 0LU, cast(Storage)cast(ubyte)6u) lazysplit.Ui.nodes
nodes
[
(parameter) lazysplit.Node n
n
.
(field) uint lazysplit.Node.index
index
];
(parameter) ulong h
h
=
ulong treehash.treeHash(ulong h, scope const(char)[] kind, uint w, uint hgt, uint children) pure nothrow @nogc @safe
treeHash
(
(parameter) ulong h
h
,
(local variable) const(lazysplit.NodeRec) r
r
.
(field) lazysplit.Kind lazysplit.NodeRec.kind
kind
.
string sparkles.base.text.enums.enumMemberName!(CaseStyle.original, lazysplit.Kind)(in lazysplit.Kind value) pure nothrow @nogc @safe

The name of the declared member equal to value, recased per style as a compile-time string literal (so the call allocates nothing).

value must be a declared member of E. The generated final switch rejects a duplicate-valued enum at compile time (duplicate case labels) and asserts on a value that is not a declared member.

enumMemberName
,
uint lazysplit.Ui.wOf(uint n) const pure nothrow @nogc @safe
wOf
(
(parameter) lazysplit.Node n
n
.
(field) uint lazysplit.Node.index
index
),
uint lazysplit.Ui.hOf(uint n) const pure nothrow @nogc @safe
hOf
(
(parameter) lazysplit.Node n
n
.
(field) uint lazysplit.Node.index
index
),
uint lazysplit.Ui.countOf(uint n) const pure nothrow @nogc @safe
countOf
(
(parameter) lazysplit.Node n
n
.
(field) uint lazysplit.Node.index
index
));
(parameter) ulong count
count
++;
foreach (
(parameter) const(uint) c
c
;
const(uint)[] lazysplit.Ui.kidsOf(uint n) const pure nothrow @nogc return @safe
kidsOf
(
(parameter) lazysplit.Node n
n
.
(field) uint lazysplit.Node.index
index
))
void lazysplit.Ui.checksum(lazysplit.Node n, ref ulong h, ref ulong count) const pure nothrow @nogc @safe

Pre-order checksum of the tree under n.

checksum
(
(struct) lazysplit.Node

A handle to a node this frame built. Children return it so a parent can tell a child built in its slot from one built earlier (see evalChild).

Node
(
(local variable) const(uint) c
c
),
(parameter) ulong h
h
,
(parameter) ulong count
count
);
} } /// Display width of UTF-8 text: one cell per code point (the trivial model). package uint
uint lazysplit.cells(scope const(char)[] s) pure nothrow @nogc @safe

Display width of UTF-8 text: one cell per code point (the trivial model).

cells
(scope const(char)[]
(parameter) const(char)[] s
s
) @safe pure nothrow @nogc
{ uint
(local variable) uint n
n
;
foreach (
(parameter) const(char) c
c
;
(parameter) const(char)[] s
s
)
(local variable) uint n
n
+= (
(local variable) const(char) c
c
& 0xC0) != 0x80;
return
(local variable) uint n
n
;
} package uint
uint lazysplit.digits(int v) pure nothrow @nogc @safe
digits
(int
(parameter) int v
v
) @safe pure nothrow @nogc
{ uint
(local variable) uint n
n
=
(parameter) int v
v
< 0 ? 2 : 1;
for (
(parameter) int v
v
/= 10; v; v /= 10)
(local variable) uint n
n
++;
return
(local variable) uint n
n
;
} private char[4]
char[4] lazysplit.hex4(ulong v) pure nothrow @nogc @safe
hex4
(ulong
(parameter) ulong v
v
) @safe pure nothrow @nogc
{ char[4]
(local variable) char[4] r
r
;
foreach (
(local variable) int i
i
; 0 .. 4)
(local variable) char[4] r
r
[
(local variable) int i
i
] = "0123456789abcdef"[(
(parameter) ulong v
v
>> (60 - 4 *
(local variable) int i
i
)) & 0xF];
return
(local variable) char[4] r
r
;
} // ── containers: `ui.column(gap: 1, children: a, b, c)` ───────────────────── /// A vertical stack. `env` and `disabled` reach its whole subtree, which is /// evaluated after it opens.
(struct) lazysplit.Node

A handle to a node this frame built. Children return it so a parent can tell a child built in its slot from one built earlier (see evalChild).

Node
lazysplit.Node lazysplit.column(ref lazysplit.Ui ui, lazysplit.NamedOnly _ = NamedOnly(), int gap = 0, bool disabled = false, lazysplit.EnvOverride env = EnvOverride(false, Env(Layout.wide, Density.comfortable, false)), lazysplit.NamedOnly _children = NamedOnly(), lazysplit.Node delegate() pure nothrow @nogc @safe[] children...) pure nothrow @nogc @safe

A vertical stack. env and disabled reach its whole subtree, which is evaluated after it opens.

column
(ref
(struct) lazysplit.Ui

The frame's builder, on its owner's stack (or heap-owned for big frames) and passed ref. Storage as in the inside-out sketch: append-only HeapBuffers for nodes and messages, a TextPool for text, an InlineBuffer scratch for ui.text, and an InSituRegion for constant messages' bytes.

Ui
(parameter) lazysplit.Ui ui
ui
,
(struct) lazysplit.NamedOnly

The sentinel in front of every attribute list, and again in front of children: a positional argument after the last named attribute would otherwise fill children silently. With it, children: is required.

NamedOnly
(parameter) lazysplit.NamedOnly _
_
=
(struct) lazysplit.NamedOnly

The sentinel in front of every attribute list, and again in front of children: a positional argument after the last named attribute would otherwise fill children silently. With it, children: is required.

NamedOnly
.
(constant) lazysplit.NamedOnly lazysplit.NamedOnly.init = NamedOnly()
init
, int
(parameter) int gap
gap
= 0, bool
(parameter) bool disabled
disabled
= false,
(struct) lazysplit.EnvOverride

Context pushed by an element on open and popped on close. A child is evaluated after its parent opens, so it reads the context directly.

EnvOverride
(parameter) lazysplit.EnvOverride env
env
=
(struct) lazysplit.EnvOverride

ditto

EnvOverride
.
(constant) lazysplit.EnvOverride lazysplit.EnvOverride.init = EnvOverride(false, Env(Layout.wide, Density.comfortable, false))
init
,
(struct) lazysplit.NamedOnly

The sentinel in front of every attribute list, and again in front of children: a positional argument after the last named attribute would otherwise fill children silently. With it, children: is required.

NamedOnly
(parameter) lazysplit.NamedOnly _children
_children
=
(struct) lazysplit.NamedOnly

The sentinel in front of every attribute list, and again in front of children: a positional argument after the last named attribute would otherwise fill children silently. With it, children: is required.

NamedOnly
.
(constant) lazysplit.NamedOnly lazysplit.NamedOnly.init = NamedOnly()
init
,
scope
(alias) lazysplit.ChildFn = lazysplit.Node delegate() pure nothrow @nogc @safe

What a child slot holds: a lazy, non-capturing-by-GC subtree builder. scope at every use site is what keeps it off the GC (with the patch).

ChildFn
[]
(parameter) lazysplit.Node delegate() pure nothrow @nogc @safe[] children
children
...) @safe pure nothrow @nogc
=>
(parameter) lazysplit.Ui ui
ui
.
lazysplit.Node lazysplit.Ui.container(lazysplit.NodeRec rec, lazysplit.EnvOverride over, bool disabled, scope lazysplit.Node delegate() pure nothrow @nogc @safe[] children) pure nothrow @nogc @safe

A container: open, evaluate each child slot in order, close.

container
(
(struct) lazysplit.NodeRec

One element, written once when it opens (its size and children once more when it closes). Children are listed, not linked: a closing element copies its children's indices from the children stack into the kids table, as Clay does, so no earlier record is ever updated.

NodeRec
(kind:
(enum) lazysplit.Kind
Kind
.
(enum value) lazysplit.Kind.column = cast(ubyte)0u
column
, gap:
(parameter) int gap
gap
),
(parameter) lazysplit.EnvOverride env
env
,
(parameter) bool disabled
disabled
,
(parameter) lazysplit.Node delegate() pure nothrow @nogc @safe[] children
children
);
/// A horizontal stack.
(struct) lazysplit.Node

A handle to a node this frame built. Children return it so a parent can tell a child built in its slot from one built earlier (see evalChild).

Node
lazysplit.Node lazysplit.row(ref lazysplit.Ui ui, lazysplit.NamedOnly _ = NamedOnly(), int gap = 0, lazysplit.NamedOnly _children = NamedOnly(), lazysplit.Node delegate() pure nothrow @nogc @safe[] children...) pure nothrow @nogc @safe

A horizontal stack.

row
(ref
(struct) lazysplit.Ui

The frame's builder, on its owner's stack (or heap-owned for big frames) and passed ref. Storage as in the inside-out sketch: append-only HeapBuffers for nodes and messages, a TextPool for text, an InlineBuffer scratch for ui.text, and an InSituRegion for constant messages' bytes.

Ui
(parameter) lazysplit.Ui ui
ui
,
(struct) lazysplit.NamedOnly

The sentinel in front of every attribute list, and again in front of children: a positional argument after the last named attribute would otherwise fill children silently. With it, children: is required.

NamedOnly
(parameter) lazysplit.NamedOnly _
_
=
(struct) lazysplit.NamedOnly

The sentinel in front of every attribute list, and again in front of children: a positional argument after the last named attribute would otherwise fill children silently. With it, children: is required.

NamedOnly
.
(constant) lazysplit.NamedOnly lazysplit.NamedOnly.init = NamedOnly()
init
, int
(parameter) int gap
gap
= 0,
(struct) lazysplit.NamedOnly

The sentinel in front of every attribute list, and again in front of children: a positional argument after the last named attribute would otherwise fill children silently. With it, children: is required.

NamedOnly
(parameter) lazysplit.NamedOnly _children
_children
=
(struct) lazysplit.NamedOnly

The sentinel in front of every attribute list, and again in front of children: a positional argument after the last named attribute would otherwise fill children silently. With it, children: is required.

NamedOnly
.
(constant) lazysplit.NamedOnly lazysplit.NamedOnly.init = NamedOnly()
init
, scope
(alias) lazysplit.ChildFn = lazysplit.Node delegate() pure nothrow @nogc @safe

What a child slot holds: a lazy, non-capturing-by-GC subtree builder. scope at every use site is what keeps it off the GC (with the patch).

ChildFn
[]
(parameter) lazysplit.Node delegate() pure nothrow @nogc @safe[] children
children
...) @safe pure nothrow @nogc
=>
(parameter) lazysplit.Ui ui
ui
.
lazysplit.Node lazysplit.Ui.container(lazysplit.NodeRec rec, lazysplit.EnvOverride over, bool disabled, scope lazysplit.Node delegate() pure nothrow @nogc @safe[] children) pure nothrow @nogc @safe

A container: open, evaluate each child slot in order, close.

container
(
(struct) lazysplit.NodeRec

One element, written once when it opens (its size and children once more when it closes). Children are listed, not linked: a closing element copies its children's indices from the children stack into the kids table, as Clay does, so no earlier record is ever updated.

NodeRec
(kind:
(enum) lazysplit.Kind
Kind
.
(enum value) lazysplit.Kind.row = 1
row
, gap:
(parameter) int gap
gap
),
(struct) lazysplit.EnvOverride

ditto

EnvOverride
.
(constant) lazysplit.EnvOverride lazysplit.EnvOverride.init = EnvOverride(false, Env(Layout.wide, Density.comfortable, false))
init
, false,
(parameter) lazysplit.Node delegate() pure nothrow @nogc @safe[] children
children
);
// ── leaves ───────────────────────────────────────────────────────────────── /// One run of text.
(struct) lazysplit.Node

A handle to a node this frame built. Children return it so a parent can tell a child built in its slot from one built earlier (see evalChild).

Node
lazysplit.Node lazysplit.label(ref lazysplit.Ui ui, lazysplit.NamedOnly _ = NamedOnly(), lazysplit.Slot slot = Slot.code, scope const(char)[] text = null) pure nothrow @nogc @safe

One run of text.

label
(ref
(struct) lazysplit.Ui

The frame's builder, on its owner's stack (or heap-owned for big frames) and passed ref. Storage as in the inside-out sketch: append-only HeapBuffers for nodes and messages, a TextPool for text, an InlineBuffer scratch for ui.text, and an InSituRegion for constant messages' bytes.

Ui
(parameter) lazysplit.Ui ui
ui
,
(struct) lazysplit.NamedOnly

The sentinel in front of every attribute list, and again in front of children: a positional argument after the last named attribute would otherwise fill children silently. With it, children: is required.

NamedOnly
(parameter) lazysplit.NamedOnly _
_
=
(struct) lazysplit.NamedOnly

The sentinel in front of every attribute list, and again in front of children: a positional argument after the last named attribute would otherwise fill children silently. With it, children: is required.

NamedOnly
.
(constant) lazysplit.NamedOnly lazysplit.NamedOnly.init = NamedOnly()
init
,
(enum) lazysplit.Slot
Slot
(parameter) lazysplit.Slot slot
slot
=
(enum) lazysplit.Slot
Slot
.
(enum value) lazysplit.Slot.code = cast(ubyte)0u
code
,
scope const(char)[]
(parameter) const(char)[] text
text
= null) @safe pure nothrow @nogc
=>
(parameter) lazysplit.Ui ui
ui
.
lazysplit.Node lazysplit.Ui.leaf(lazysplit.NodeRec rec, uint w) pure nothrow @nogc @safe

A leaf: open and close at once, with its own content size.

leaf
(
(struct) lazysplit.NodeRec

One element, written once when it opens (its size and children once more when it closes). Children are listed, not linked: a closing element copies its children's indices from the children stack into the kids table, as Clay does, so no earlier record is ever updated.

NodeRec
(kind:
(enum) lazysplit.Kind
Kind
.
(enum value) lazysplit.Kind.label = 2
label
, slot:
(parameter) lazysplit.Slot slot
slot
, text:
(parameter) lazysplit.Ui ui
ui
.
benchtext.BumpTextPool.Id lazysplit.Ui.intern(scope const(char)[] s) pure nothrow @nogc @safe
intern
(
(parameter) const(char)[] text
text
)),
(parameter) const(char)[] text
text
.
uint lazysplit.cells(scope const(char)[] s) pure nothrow @nogc @safe

Display width of UTF-8 text: one cell per code point (the trivial model).

cells
);
/// A switch; `onPress` is whatever message the caller wants on a press.
(struct) lazysplit.Node

A handle to a node this frame built. Children return it so a parent can tell a child built in its slot from one built earlier (see evalChild).

Node
lazysplit.Node lazysplit.toggle(ref lazysplit.Ui ui, lazysplit.NamedOnly _ = NamedOnly(), bool on = false, scope const(char)[] label = null, lazysplit.MsgRef onPress = MsgRef(4294967295u)) pure nothrow @nogc @safe

A switch; onPress is whatever message the caller wants on a press.

toggle
(ref
(struct) lazysplit.Ui

The frame's builder, on its owner's stack (or heap-owned for big frames) and passed ref. Storage as in the inside-out sketch: append-only HeapBuffers for nodes and messages, a TextPool for text, an InlineBuffer scratch for ui.text, and an InSituRegion for constant messages' bytes.

Ui
(parameter) lazysplit.Ui ui
ui
,
(struct) lazysplit.NamedOnly

The sentinel in front of every attribute list, and again in front of children: a positional argument after the last named attribute would otherwise fill children silently. With it, children: is required.

NamedOnly
(parameter) lazysplit.NamedOnly _
_
=
(struct) lazysplit.NamedOnly

The sentinel in front of every attribute list, and again in front of children: a positional argument after the last named attribute would otherwise fill children silently. With it, children: is required.

NamedOnly
.
(constant) lazysplit.NamedOnly lazysplit.NamedOnly.init = NamedOnly()
init
, bool
(parameter) bool on
on
= false,
scope const(char)[]
(parameter) const(char)[] label
label
= null,
(struct) lazysplit.MsgRef

An erased message: an index into the frame's message table.

MsgRef
(parameter) lazysplit.MsgRef onPress
onPress
=
(struct) lazysplit.MsgRef

An erased message: an index into the frame's message table.

MsgRef
.
(constant) lazysplit.MsgRef lazysplit.MsgRef.init = MsgRef(4294967295u)
init
) @safe pure nothrow @nogc
=>
(parameter) lazysplit.Ui ui
ui
.
lazysplit.Node lazysplit.Ui.leaf(lazysplit.NodeRec rec, uint w) pure nothrow @nogc @safe

A leaf: open and close at once, with its own content size.

leaf
(
(struct) lazysplit.NodeRec

One element, written once when it opens (its size and children once more when it closes). Children are listed, not linked: a closing element copies its children's indices from the children stack into the kids table, as Clay does, so no earlier record is ever updated.

NodeRec
(kind:
(enum) lazysplit.Kind
Kind
.
(enum value) lazysplit.Kind.toggle = 3
toggle
, on:
(parameter) bool on
on
, text:
(parameter) lazysplit.Ui ui
ui
.
benchtext.BumpTextPool.Id lazysplit.Ui.intern(scope const(char)[] s) pure nothrow @nogc @safe
intern
(
(parameter) const(char)[] label
label
), msg:
(parameter) lazysplit.MsgRef onPress
onPress
),
(parameter) const(char)[] label
label
.
uint lazysplit.cells(scope const(char)[] s) pure nothrow @nogc @safe

Display width of UTF-8 text: one cell per code point (the trivial model).

cells
+ 4);
/// A number field; `onChange` carries the new value as an `int` payload.
(struct) lazysplit.Node

A handle to a node this frame built. Children return it so a parent can tell a child built in its slot from one built earlier (see evalChild).

Node
lazysplit.Node lazysplit.numberField(ref lazysplit.Ui ui, lazysplit.NamedOnly _ = NamedOnly(), int value = 0, scope const(char)[] unit = null, lazysplit.MsgRef onChange = MsgRef(4294967295u)) pure nothrow @nogc @safe

A number field; onChange carries the new value as an int payload.

numberField
(ref
(struct) lazysplit.Ui

The frame's builder, on its owner's stack (or heap-owned for big frames) and passed ref. Storage as in the inside-out sketch: append-only HeapBuffers for nodes and messages, a TextPool for text, an InlineBuffer scratch for ui.text, and an InSituRegion for constant messages' bytes.

Ui
(parameter) lazysplit.Ui ui
ui
,
(struct) lazysplit.NamedOnly

The sentinel in front of every attribute list, and again in front of children: a positional argument after the last named attribute would otherwise fill children silently. With it, children: is required.

NamedOnly
(parameter) lazysplit.NamedOnly _
_
=
(struct) lazysplit.NamedOnly

The sentinel in front of every attribute list, and again in front of children: a positional argument after the last named attribute would otherwise fill children silently. With it, children: is required.

NamedOnly
.
(constant) lazysplit.NamedOnly lazysplit.NamedOnly.init = NamedOnly()
init
, int
(parameter) int value
value
= 0,
scope const(char)[]
(parameter) const(char)[] unit
unit
= null,
(struct) lazysplit.MsgRef

An erased message: an index into the frame's message table.

MsgRef
(parameter) lazysplit.MsgRef onChange
onChange
=
(struct) lazysplit.MsgRef

An erased message: an index into the frame's message table.

MsgRef
.
(constant) lazysplit.MsgRef lazysplit.MsgRef.init = MsgRef(4294967295u)
init
) @safe pure nothrow @nogc
=>
(parameter) lazysplit.Ui ui
ui
.
lazysplit.Node lazysplit.Ui.leaf(lazysplit.NodeRec rec, uint w) pure nothrow @nogc @safe

A leaf: open and close at once, with its own content size.

leaf
(
(struct) lazysplit.NodeRec

One element, written once when it opens (its size and children once more when it closes). Children are listed, not linked: a closing element copies its children's indices from the children stack into the kids table, as Clay does, so no earlier record is ever updated.

NodeRec
(kind:
(enum) lazysplit.Kind
Kind
.
(enum value) lazysplit.Kind.numberField = 4
numberField
, value:
(parameter) int value
value
, text:
(parameter) lazysplit.Ui ui
ui
.
benchtext.BumpTextPool.Id lazysplit.Ui.intern(scope const(char)[] s) pure nothrow @nogc @safe
intern
(
(parameter) const(char)[] unit
unit
),
msg:
(parameter) lazysplit.MsgRef onChange
onChange
),
(parameter) int value
value
.
uint lazysplit.digits(int v) pure nothrow @nogc @safe
digits
+ 1 +
(parameter) const(char)[] unit
unit
.
uint lazysplit.cells(scope const(char)[] s) pure nothrow @nogc @safe

Display width of UTF-8 text: one cell per code point (the trivial model).

cells
);
/// A name and its value; pressing it sends `onPress`.
(struct) lazysplit.Node

A handle to a node this frame built. Children return it so a parent can tell a child built in its slot from one built earlier (see evalChild).

Node
lazysplit.Node lazysplit.keyValue(ref lazysplit.Ui ui, lazysplit.NamedOnly _ = NamedOnly(), scope const(char)[] name = null, scope const(char)[] value = null, lazysplit.MsgRef onPress = MsgRef(4294967295u)) pure nothrow @nogc @safe

A name and its value; pressing it sends onPress.

keyValue
(ref
(struct) lazysplit.Ui

The frame's builder, on its owner's stack (or heap-owned for big frames) and passed ref. Storage as in the inside-out sketch: append-only HeapBuffers for nodes and messages, a TextPool for text, an InlineBuffer scratch for ui.text, and an InSituRegion for constant messages' bytes.

Ui
(parameter) lazysplit.Ui ui
ui
,
(struct) lazysplit.NamedOnly

The sentinel in front of every attribute list, and again in front of children: a positional argument after the last named attribute would otherwise fill children silently. With it, children: is required.

NamedOnly
(parameter) lazysplit.NamedOnly _
_
=
(struct) lazysplit.NamedOnly

The sentinel in front of every attribute list, and again in front of children: a positional argument after the last named attribute would otherwise fill children silently. With it, children: is required.

NamedOnly
.
(constant) lazysplit.NamedOnly lazysplit.NamedOnly.init = NamedOnly()
init
, scope const(char)[]
(parameter) const(char)[] name
name
= null,
scope const(char)[]
(parameter) const(char)[] value
value
= null,
(struct) lazysplit.MsgRef

An erased message: an index into the frame's message table.

MsgRef
(parameter) lazysplit.MsgRef onPress
onPress
=
(struct) lazysplit.MsgRef

An erased message: an index into the frame's message table.

MsgRef
.
(constant) lazysplit.MsgRef lazysplit.MsgRef.init = MsgRef(4294967295u)
init
) @safe pure nothrow @nogc
=>
(parameter) lazysplit.Ui ui
ui
.
lazysplit.Node lazysplit.Ui.leaf(lazysplit.NodeRec rec, uint w) pure nothrow @nogc @safe

A leaf: open and close at once, with its own content size.

leaf
(
(struct) lazysplit.NodeRec

One element, written once when it opens (its size and children once more when it closes). Children are listed, not linked: a closing element copies its children's indices from the children stack into the kids table, as Clay does, so no earlier record is ever updated.

NodeRec
(kind:
(enum) lazysplit.Kind
Kind
.
(enum value) lazysplit.Kind.keyValue = 5
keyValue
, text:
(parameter) lazysplit.Ui ui
ui
.
benchtext.BumpTextPool.Id lazysplit.Ui.intern(scope const(char)[] s) pure nothrow @nogc @safe
intern
(
(parameter) const(char)[] name
name
), text2:
(parameter) lazysplit.Ui ui
ui
.
benchtext.BumpTextPool.Id lazysplit.Ui.intern(scope const(char)[] s) pure nothrow @nogc @safe
intern
(
(parameter) const(char)[] value
value
),
msg:
(parameter) lazysplit.MsgRef onPress
onPress
),
(parameter) const(char)[] name
name
.
uint lazysplit.cells(scope const(char)[] s) pure nothrow @nogc @safe

Display width of UTF-8 text: one cell per code point (the trivial model).

cells
+ 1 +
(parameter) const(char)[] value
value
.
uint lazysplit.cells(scope const(char)[] s) pure nothrow @nogc @safe

Display width of UTF-8 text: one cell per code point (the trivial model).

cells
);
// ── lists: keys are mandatory ────────────────────────────────────────────── /// A range bound to the builder. It offers `mapKeyed` and `mapByIndex`, and no /// plain `map`: it is not an input range, so Phobos' `map` does not apply. struct
(struct) lazysplit.UiRange(R)

A range bound to the builder. It offers mapKeyed and mapByIndex, and no plain map: it is not an input range, so Phobos' map does not apply.

UiRange
(R)
{ private R
_error_ range
range
;
private
(unresolved type) Ui
Ui
*
_error_ ui
ui
;
} /// ditto auto
auto toUi(R)(R r, return ref Ui ui)

A range bound to the builder. It offers mapKeyed and mapByIndex, and no plain map: it is not an input range, so Phobos' map does not apply.

toUi
(R)(R
(parameter) R r
r
, return ref
(unresolved type) Ui
Ui
(parameter) Ui ui
ui
) =>
(template instance) UiRange!R
UiRange
!R(r, &ui);
/** Splices one keyed row per element into the argument position it occupies: no fragment node, so the rows are the parent's own children for layout (as Clay's would be). It is itself a lazy child, so it runs while the parent is open. A free function, not a `Ui` method: a method template taking a local lambda by alias needs a dual context. */ Node
Node mapKeyed(alias key, alias row, R)(UiRange!R r)

Splices one keyed row per element into the argument position it occupies: no fragment node, so the rows are the parent's own children for layout (as Clay's would be). It is itself a lazy child, so it runs while the parent is open. A free function, not a Ui method: a method template taking a local lambda by alias needs a dual context.

mapKeyed
(alias key, alias row, R)(UiRange!R
(parameter) UiRange!R r
r
)
{ auto
_error_ ui
ui
= r.
r.ui
ui
;
const
_error_ pos
pos
= ui.
ui.nextPos
nextPos
;
foreach (ref
(parameter) e
e
; r.
r.range
range
)
{ ui.
ui.nextKeyed
nextKeyed
= true;
ui.
ui.nextKey
nextKey
= hashOf(key(e));
cast(void) ui.
ui.evalChild
evalChild
(pos, () => row(e));
} ui.
ui.nextKeyed
nextKeyed
= false;
return Node.
Node.none
none
; // the rows are linked already; the slot itself is empty
} /// ditto, opting into position as the key (static or append-only lists). Node
Node mapByIndex(alias row, R)(UiRange!R r)

ditto, opting into position as the key (static or append-only lists).

mapByIndex
(alias row, R)(UiRange!R
(parameter) UiRange!R r
r
)
{ auto
_error_ ui
ui
= r.
r.ui
ui
;
const
_error_ pos
pos
= ui.
ui.nextPos
nextPos
;
ulong
_error_ i
i
;
foreach (ref
(parameter) e
e
; r.
r.range
range
)
{ ui.
ui.nextKeyed
nextKeyed
= true;
ui.
ui.nextKey
nextKey
= i++;
cast(void) ui.
ui.evalChild
evalChild
(pos, () => row(e));
} ui.
ui.nextKeyed
nextKeyed
= false;
return Node.
Node.none
none
;
} // ── messages ─────────────────────────────────────────────────────────────── /// A constant message, copied into the frame's table. Checked (debug, at run /// time) against the open `mapMsg` scope: the child is evaluated inside it. MsgRef
MsgRef on(M)(ref Ui ui, M value)

A constant message, copied into the frame's table. Checked (debug, at run time) against the open mapMsg scope: the child is evaluated inside it.

on
(M)(ref
(unresolved type) Ui
Ui
(parameter) Ui ui
ui
, M
(parameter) M value
value
)
{ static assert(__traits(isPOD, M), "a message is plain data: it is copied as bytes"); ui.
ui.checkMsg
checkMsg
(
(template instance) typeKey!M
typeKey
!M, M.stringof);
return ui.
ui.addMsg
addMsg
(MsgRec(typeKey:
(template instance) typeKey!M
typeKey
!M, value: ui.
ui.keep
keep
(value)));
} /// A message built from a component's payload. `fn` may not capture. MsgRef
MsgRef on(alias fn)(ref Ui ui)

A message built from a component's payload. fn may not capture.

on
(alias fn)(ref
(unresolved type) Ui
Ui
(parameter) Ui ui
ui
)
{ ui.
ui.checkMsg
checkMsg
(
(template instance) typeKey!(ReturnType!fn)
typeKey
!(ReturnType!fn),
(template instance) ReturnType!fn
ReturnType
!fn.stringof);
return ui.
ui.addMsg
addMsg
(MsgRec(typeKey:
(template instance) typeKey!(ReturnType!fn)
typeKey
!(ReturnType!fn), payload: &
(template instance) applyErased!fn
applyErased
!fn,
payloadKey:
(template instance) typeKey!(Parameters!fn[0])
typeKey
!(Parameters!fn[0])));
} /** Lifts every message its child sends with `fn`. The child is lazy, so it is evaluated *inside* the scope: each `ui.on` below sees `From` as the expected type and checks against it right there. */ Node
Node mapMsg(alias fn)(ref Ui ui, scope ChildFn[] children...)

Lifts every message its child sends with fn. The child is lazy, so it is evaluated inside the scope: each ``ui.on below sees From as the expected type and checks against it right there.

mapMsg
(alias fn)(ref
(unresolved type) Ui
Ui
(parameter) Ui ui
ui
, scope
(unresolved type) ChildFn
ChildFn
[]
(parameter) ChildFn[] children
children
...)
{ alias
(alias) From = Parameters!fn[0]
From
= Parameters!fn[0];
alias
(alias) To = ReturnType!fn
To
= ReturnType!fn;
debug if (typeKey!To != ui.msgKey) ui.diags ~= Diag(DiagKind.mapMsgTargetMismatch, ui.top, got: To.stringof, expected: ui.msgName); const
_error_ saved
saved
= ui.
ui.currentEnv
currentEnv
;
const
_error_ savedKey
savedKey
= ui.
ui.msgKey
msgKey
;
const
_error_ savedName
savedName
= ui.
ui.msgName
msgName
;
const
_error_ self
self
= ui.
ui.open
open
(NodeRec(kind: Kind.
Kind.mapMsg
mapMsg
, map: MapRec(from:
(template instance) typeKey!From
typeKey
!
(unresolved type) From
From
,
to:
(template instance) typeKey!To
typeKey
!
(unresolved type) To
To
, apply: &
(template instance) applyErased!fn
applyErased
!fn, fromName: From.stringof, toName: To.stringof)),
EnvOverride.
EnvOverride.init
init
, false);
ui.
ui.msgKey
msgKey
=
(template instance) typeKey!From
typeKey
!
(unresolved type) From
From
;
ui.
ui.msgName
msgName
= From.stringof;
foreach (
(parameter) i
i
,
(parameter) child
child
; children)
cast(void) ui.
ui.evalChild
evalChild
(cast(uint) i, child);
ui.
ui.msgKey
msgKey
= savedKey;
ui.
ui.msgName
msgName
= savedName;
ui.
ui.close
close
(saved);
return Node(self); } /// `fn`, erased: reads its argument at `from`, emplaces its result at `to`. private void
@system void applyErased(alias fn)(scope const(void)* from, scope void* to)

fn, erased: reads its argument at from, emplaces its result at to.

applyErased
(alias fn)(scope const(void)*
(parameter) const(void)* from
from
, scope void*
(parameter) void* to
to
) @system
{ alias
(alias) Src = Parameters!fn[0]
Src
= const Parameters!fn[0];
alias
(alias) Dst = ReturnType!fn
Dst
= ReturnType!fn;
emplace(cast(
(unresolved type) Dst
Dst
*) to, fn(*cast(
(unresolved type) Src
Src
*) from));
} // ── memo seam ────────────────────────────────────────────────────────────── /** A memo site (UI-Q3's seam): a `memo` element keyed by `fn`'s arguments and the env, then `fn(ui, args)` built as its one child. A real host compares the key with last frame's element of the same id and, when equal, splices last frame's subtree instead of calling `fn`. */ Node
Node memo(alias fn, Args...)(ref Ui ui, auto ref const Args args)

A memo site (UI-Q3's seam): a memo element keyed by fn's arguments and the env, then fn(ui, args) built as its one child. A real host compares the key with last frame's element of the same id and, when equal, splices last frame's subtree instead of calling fn.

memo
(alias fn, Args...)(ref
(unresolved type) Ui
Ui
(parameter) Ui ui
ui
, auto ref const Args
(parameter) Args args
args
)
{ static assert(
(template instance) functionAttributes!fn
functionAttributes
!fn & FunctionAttribute.pure_,
"a memoised composite must be `pure`"); ulong
_error_ key
key
= hashOf(ui.
ui.currentEnv
currentEnv
);
static foreach (i; 0 .. Args.length) key = mix(key, hashOf(args[i])); const
_error_ saved
saved
= ui.
ui.currentEnv
currentEnv
;
const
_error_ self
self
= ui.
ui.open
open
(NodeRec(kind: Kind.
Kind.memo
memo
, memoKey: key), EnvOverride.
EnvOverride.init
init
, false);
cast(void) ui.
ui.evalChild
evalChild
(0, () => fn(ui, args));
ui.
ui.close
close
(saved);
return Node(self); } version (
Bench
Bench
) pragma(msg, __MODULE__, ": NodeRec.sizeof = ", NodeRec.sizeof);