package matryoshka:examples/block1
Index
Constants (0)
This section is empty.
Variables (2)
Procedure Groups (0)
This section is empty.
Types
Builder ¶
Builder :: struct { alloc: runtime.Allocator, }
Builder provides functions to construct and destruct PolyNode-based items with different types. Very naive - don't use in produnction
Related Procedures With Returns
Event ¶
Event :: struct { using poly: matryoshka.PolyNode, // offset 0 — required for safe cast code: untyped integer, message: string, }
Event carries a numeric code and a human-readable message.
MayItem ¶
MayItem :: runtime.Maybe($T=^PolyNode)
Alias for matryoshka.MayItem — ownership handle.
Related Procedures With Parameters
Related Procedures With Returns
PolyNode ¶
PolyNode :: matryoshka.PolyNode
Alias for matryoshka.PolyNode — shortens usage across this package.
Sensor ¶
Sensor :: struct { using poly: matryoshka.PolyNode, // offset 0 — required for safe cast name: string, value: f64, }
Sensor carries a name and a floating-point measurement.
Constants
This section is empty.
Variables
Procedures
consume_list ¶
consume_list pops and frees all remaining items in the list.
ctor ¶
ctor allocates the correct type for tag and sets tag. Returns nil for unknown tags.
dtor ¶
dtor frees internal resources and the node, then sets m^ = nil. Safe to call with m == nil or m^ == nil (no-op).
event_is_it_you ¶
event_is_it_you reports whether tag belongs to an Event.
example_builder ¶
example_builder creates items via Builder, uses them, and destroys them. Returns true if roundtrip succeeds.
example_ownership ¶
After push you no longer own the item. After pop you own it and must free or transfer it.
example_produce_consume ¶
example_produce_consume allocates a mix of Event and Sensor items, pushes them onto an intrusive list, then pops and dispatches on tag. Returns true if every item was processed and freed with no leaks.
make_builder ¶
make_builder creates a Builder with the given allocator.
run_poly_maybe_example ¶
run_poly_maybe_example :: proc() -> bool {…}
run_poly_maybe_example demonstrates the core PolyNode + MayItem pattern.
Creates an Event, wraps it in MayItem, transfers it through an intrusive list, pops it back, verifies, and frees. Returns true on success.
sensor_is_it_you ¶
sensor_is_it_you reports whether tag belongs to a Sensor.
Procedure Groups
This section is empty.