|
x-engine-c v0.2.13
The C engine for x-lang
|
Iterator type implementation (lazy traversal of sequences). More...
Functions | |
| x_obj_t * | x_make_iter (x_obj_t *p_base, x_obj_flag_t flags, void *p1, void *p2) |
| x_obj_t * | x_type_iter_struct (x_obj_t *p_base, x_obj_t *p_args) |
| x_obj_t * | x_type_iter_register (x_obj_t *p_base, x_obj_t *p_args) |
| x_obj_t * | x_type_iter_make (x_obj_t *p_base, x_obj_t *p_args) |
| x_obj_t * | x_type_iter_next (x_obj_t *p_base, x_obj_t *p_args) |
| x_obj_t * | x_type_iter_step (x_obj_t *p_base, x_obj_t *p_args) |
Variables | |
| x_satom_t | x_type_iter_name = x_obj_set(x_type_atom_obj, X_OBJ_FLAG_NONE, { .s = (x_char_t *)X_TYPE_ITER_NAME }) |
| x_satom_t | x_type_iter_make_prim = x_obj_set(x_type_atom_obj, X_OBJ_FLAG_NONE, { (x_obj_t *)&x_type_iter_make }) |
| x_satom_t | x_type_iter_struct_prim = x_obj_set(x_type_atom_obj, X_OBJ_FLAG_NONE, { (x_obj_t *)&x_type_iter_struct }) |
Iterator type implementation (lazy traversal of sequences).
| x_obj_t * x_make_iter | ( | x_obj_t * | p_base, |
| x_obj_flag_t | flags, | ||
| void * | p1, | ||
| void * | p2 | ||
| ) |
Allocate a new iterator object on the heap.
The iterator stores a step function (p1) and a current value (p2) in the standard pair layout.
| p_base | x_obj_t* – Base (execution context) |
| flags | x_obj_flag_t – Object flags |
| p1 | void* – Step function (callable) |
| p2 | void* – Initial value (nil when exhausted) |
Type-dispatch make callback: construct an iterator from x-lang args.
Expects args: ((step-fn . value) [flags]).
| p_base | x_obj_t* – Base (execution context) |
| p_args | x_obj_t* – Construction arguments |
Advance an iterator by one step.
The iterator is a boxed GENERATOR: (step . state). Steps are pure – they never mutate the box; this driver owns the single write-back. Two step ABIs, discriminated exactly as x_callable_call does:
| p_base | x_obj_t* – Base (execution context) |
| p_args | x_obj_t* – (iterator) |
Register (or retrieve) the ITER type struct on p_base.
| p_base | x_obj_t* – Base (execution context) |
| p_args | x_obj_t* – Unused |
Step an iterator FUNCTIONALLY – no mutation, generator view.
The persistent complement of x_type_iter_next: yields (value . next-iterator) as a fresh pair (the Seq step shape), leaving the given iterator untouched, or nil when it is exhausted. This is the X-boundary door that lets Gen pipelines run on C steps; the two allocations happen here, where allocation is legal.
| p_base | x_obj_t* – Base (execution context) |
| p_args | x_obj_t* – (iterator) |
Build the ITER type struct descriptor.
| p_base | x_obj_t* – Base (execution context) |
| p_args | x_obj_t* – Unused |
| x_satom_t x_type_iter_make_prim = x_obj_set(x_type_atom_obj, X_OBJ_FLAG_NONE, { (x_obj_t *)&x_type_iter_make }) |
| x_satom_t x_type_iter_name = x_obj_set(x_type_atom_obj, X_OBJ_FLAG_NONE, { .s = (x_char_t *)X_TYPE_ITER_NAME }) |
| x_satom_t x_type_iter_struct_prim = x_obj_set(x_type_atom_obj, X_OBJ_FLAG_NONE, { (x_obj_t *)&x_type_iter_struct }) |