Documentation ¶
Overview ¶
Package inspect provides depth first iteration a tapestry command or slice of commands.
Index ¶
- Variables
- func Visit(i typeinfo.Instance, evt Events) (err error)
- type Callbacks
- type Ender
- type Events
- type It
- func (w *It) CompactValue() (ret any)
- func (w *It) Float() float64
- func (w *It) GetSlot(ptr any) (okay bool)
- func (w *It) IsZero() (okay bool)
- func (w *It) Len() (ret int)
- func (w *It) Markup(ensure bool) (ret map[string]any)
- func (w *It) Next() (okay bool)
- func (w *It) RawValue() r.Value
- func (w *It) Repeating() bool
- func (w *It) Resize(cnt int)
- func (w *It) SetSlot(val typeinfo.Instance) (okay bool)
- func (w *It) SetValue(val any) (okay bool)
- func (w *It) String() (ret string)
- func (w *It) Term() (ret typeinfo.Term)
- func (w *It) TypeInfo() typeinfo.T
- func (w *It) Walk() (ret It)
- type Stack
Constants ¶
This section is empty.
Variables ¶
var ErrDone = errors.New("done visiting")
can be used to early exit from visiting caller still has to check for this to disambiguate the returned error
Functions ¶
Types ¶
type Callbacks ¶
type Callbacks struct { OnFlow func(It) error OnField func(It) error OnSlot func(It) error OnRepeat func(It) error OnValue func(It) error OnEnd func(It) error }
implements the Events interface
type Events ¶
type Events interface { Flow(It) error // called for every member of a flow. Field(It) error // called for a member slot: can be an empty slot. Slot(It) error // called for a member that repeats; can be an empty list. Repeat(It) error // called for each str or num in a flow, or in a repeat. // because it isnt a container, there is no matching end. Value(It) error // called after each flow, slot, or repeat. End(It) error }
fix? this should probably be passing type info and not walker itself
type It ¶
type It struct {
// contains filtered or unexported fields
}
If a command, a slot for a command, and slices of commands or slots, can all be thought of as containers of values, where values are primitive values or other containers, then It provides a depth first traversal of those values. In this context, a slice of primitives values is handled treated as a single value.
func Walk ¶
Provides iteration of tapestry commands. The returned It starts pointing to the passed container, calling Next advances to each element of the container in turn. Containers can be a single command, a slot for a command, or slices of commands or slots; other values have undefined results and may panic.
func (*It) CompactValue ¶
returns the value of the current focus as it would appear in file. enums use lower_case strings, while bool uses true/false. falls back to the container itself if Next() has yet to be called.
func (*It) IsZero ¶
returns whether the focused value is at its default value. falls back to the container itself if Next() has yet to be called.
func (*It) Len ¶
Returns the number of repeated elements in the current container; doesn't change over the course of iteration. Filled slots have one element; empty slots zero elements.
func (*It) Markup ¶
metadata for the currently focused element. only valid flow; returns nil otherwise
func (*It) RawValue ¶
fix: backwards compatibility. what are the use cases and what should be brought in here?
func (*It) SetValue ¶
fix? feels like this should match the way Get works. write a value into the target of an iterator. returns false if the value is incompatible ( uses go rules of conversion when needed to complete the assignment )
func (*It) String ¶
turn a Str value into a string; panics otherwise. as a special case, knows to transform boolean values to "true" or "false"