Pair type implementation.
More...
Pair type implementation.
- Author
- Jon Ruttan (jonru.nosp@m.ttan.nosp@m.@gmai.nosp@m.l.co.nosp@m.m)
- Copyright
- 2021 Jon Ruttan @license MIT No Attribution (MIT-0)
◆ x_make_pair()
Allocate a heap pair from first/rest pointers.
Wraps p1 and p2 in stack-allocated objects, builds a stack arg list, and delegates to x_type_pair_make.
- Parameters
-
| p_base | x_obj_t* – Base (execution context) |
| flags | x_obj_flag_t – Object flags |
| p1 | void* – First element |
| p2 | void* – Rest element |
- Returns
- x_obj_t* – New heap-allocated pair
◆ x_type_pair_length()
Compute the length of a pair list by walking rest pointers.
- Parameters
-
| p_base | x_obj_t* – Base (execution context) |
| p_args | x_obj_t* – (pair-object . ...) |
- Returns
- x_obj_t* – Integer object with list length
◆ x_type_pair_make()
Type-system make callback for pair objects.
Extracts first/rest from the pair arg and optional flags, then allocates a heap pair via x_obj_make.
- Parameters
-
| p_base | x_obj_t* – Base (execution context) |
| p_args | x_obj_t* – (pair-value . (flags | nil)) |
- Returns
- x_obj_t* – New heap-allocated pair object
◆ x_type_pair_register()
Register or retrieve the pair type on the base context.
- Parameters
-
| p_base | x_obj_t* – Base (execution context) |
| p_args | x_obj_t* – Unused |
- Returns
- x_obj_t* – Registered type object
◆ x_type_pair_struct()
Build the pair type descriptor struct.
Populates name, units, make, length, and write callbacks.
- Parameters
-
| p_base | x_obj_t* – Base (execution context) |
| p_args | x_obj_t* – Unused |
- Returns
- x_obj_t* – Type descriptor pair list
◆ x_type_pair_length_prim
◆ x_type_pair_make_prim
◆ x_type_pair_name
◆ x_type_pair_struct_prim