x-engine-c v0.2.31
The C engine for x-lang
Loading...
Searching...
No Matches
vector.c File Reference

Vector type – construction and registration. More...

#include <stdarg.h>
#include "x-type/vector.h"
#include "x-type/int.h"
#include "x-eval.h"
#include "x-eval-slots.h"
#include "x-obj/prim.h"

Functions

x_obj_t * x_make_vector (x_obj_t *p_base, x_obj_flag_t flags, x_int_t length,...)
 
x_obj_t * x_type_vector_length (x_obj_t *p_base, x_obj_t *p_args)
 
x_obj_t * x_type_vector_struct (x_obj_t *p_base, x_obj_t *p_args)
 
x_obj_t * x_type_vector_register (x_obj_t *p_base, x_obj_t *p_args)
 

Variables

x_satom_t x_type_vector_name = x_obj_set(x_type_atom_obj, X_OBJ_FLAG_NONE, { .s = (x_char_t *)X_TYPE_VECTOR_NAME })
 
x_satom_t x_type_vector_length_prim = x_obj_set(x_type_atom_obj, X_OBJ_FLAG_NONE, { (x_obj_t *)&x_type_vector_length })
 
x_satom_t x_type_vector_struct_prim = x_obj_set(x_type_atom_obj, X_OBJ_FLAG_NONE, { (x_obj_t *)&x_type_vector_struct })
 
static x_satom_t x_type_vector_units_obj
 

Detailed Description

Vector type – construction and registration.

Author
Jon Ruttan (jonru.nosp@m.ttan.nosp@m.@gmai.nosp@m.l.co.nosp@m.m)

Function Documentation

◆ x_make_vector()

x_obj_t * x_make_vector ( x_obj_t *  p_base,
x_obj_flag_t  flags,
x_int_t  length,
  ... 
)

Allocate a VECTOR object holding the objects that follow.

The length is an INTEGER object of its own, as the length of a vector x-lang makes is, so the two are read the same way.

Parameters
p_baseBase (execution context).
flagsObject flags.
lengthThe number of elements.
...The elements, length of them, each an x_obj_t *.
Returns
Newly allocated VECTOR object.

◆ x_type_vector_length()

x_obj_t * x_type_vector_length ( x_obj_t *  p_base,
x_obj_t *  p_args 
)

Type-system length handler for VECTOR objects.

Parameters
p_baseBase (execution context).
p_argsArgument list: (vector . ...).
Returns
The vector's length object.

◆ x_type_vector_register()

x_obj_t * x_type_vector_register ( x_obj_t *  p_base,
x_obj_t *  p_args 
)

Register (or retrieve) the VECTOR type in the type alist.

Calls x_type_struct_get() with the VECTOR name and struct constructor,

Parameters
p_baseBase (execution context).
p_argsUnused.
Returns
The registered VECTOR type object.

◆ x_type_vector_struct()

x_obj_t * x_type_vector_struct ( x_obj_t *  p_base,
x_obj_t *  p_args 
)

Build the VECTOR type struct descriptor.

Populates the name, the unit count and the length handler for the type system. With no save handler of its own the type takes the default, which writes the units the count declares: the length, then the elements, each a reference.

Parameters
p_baseBase (execution context).
p_argsUnused.
Returns
Type struct pair-tree for VECTOR.

Variable Documentation

◆ x_type_vector_length_prim

◆ x_type_vector_name

◆ x_type_vector_struct_prim

◆ x_type_vector_units_obj

x_satom_t x_type_vector_units_obj
static
Initial value:
=
#define X_TYPE_VECTOR_UNITS
Definition vector.h:40
@ X_OBJ_FLAG_NONE
Definition x-obj.h:131
#define x_obj_set(T, F,...)
Definition x-obj.h:344

The type's unit count: a bare count, so every unit is a reference.