package matryoshka:examples/block1

⌘K
Ctrl+K
or
/

    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 Parameters
    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.

    PolyTag ¶

    PolyTag :: matryoshka.PolyTag
     

    Alias for matryoshka.PolyTag — tag type for item identity.

    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

    EVENT_TAG ¶

    EVENT_TAG: rawptr = …
     

    EVENT_TAG is the unique tag for Event items.

    SENSOR_TAG ¶

    SENSOR_TAG: rawptr = …
     

    SENSOR_TAG is the unique tag for Sensor items.

    Procedures

    consume_list ¶

    consume_list :: proc(l: ^container_intrusive_list.List, alloc: runtime.Allocator) {…}
     

    consume_list pops and frees all remaining items in the list.

    ctor ¶

    ctor :: proc(b: ^Builder, tag: rawptr) -> runtime.Maybe($T=^PolyNode) {…}
     

    ctor allocates the correct type for tag and sets tag. Returns nil for unknown tags.

    dtor ¶

    dtor :: proc(b: ^Builder, m: ^runtime.Maybe($T=^PolyNode)) {…}
     

    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 :: proc(tag: rawptr) -> bool {…}
     

    event_is_it_you reports whether tag belongs to an Event.

    example_builder ¶

    example_builder :: proc(alloc: runtime.Allocator) -> bool {…}
     

    example_builder creates items via Builder, uses them, and destroys them. Returns true if roundtrip succeeds.

    example_ownership ¶

    example_ownership :: proc(alloc: runtime.Allocator) -> bool {…}
     

    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 :: proc(alloc: runtime.Allocator) -> bool {…}
     

    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 :: proc(alloc: runtime.Allocator) -> 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 :: proc(tag: rawptr) -> bool {…}
     

    sensor_is_it_you reports whether tag belongs to a Sensor.

    Procedure Groups

    This section is empty.

    Source Files