Boron 2.1.0
UDatatype Struct Reference

The UDatatype struct holds methods for a specific class of data. More...

Data Fields

const char * name
 ASCII name of type, ending with '!'.
 
int(* make )(UThread *, const UCell *from, UCell *res)
 Make a new instance of the type.
 
int(* convert )(UThread *, const UCell *from, UCell *res)
 Convert data to a new instance of the type.
 
void(* copy )(UThread *, const UCell *from, UCell *res)
 Make a clone of an existing value.
 
int(* compare )(UThread *, const UCell *a, const UCell *b, int test)
 Perform a comparison between cells.
 
int(* operate )(UThread *, const UCell *, const UCell *, UCell *res, int)
 Perform an operation on two cells.
 
const UCell *(* select )(UThread *, const UCell *, const UCell *sel, UCell *tmp)
 Get the value which a path node references.
 
void(* toString )(UThread *, const UCell *cell, UBuffer *str, int depth)
 Convert cell to its string data representation.
 
void(* toText )(UThread *, const UCell *cell, UBuffer *str, int depth)
 Convert cell to its string textual representation.
 
void(* recycle )(UThread *, int phase)
 Performs thread global garbage collection duties for the datatype.
 
void(* mark )(UThread *, UCell *cell)
 Responsible for marking any buffers referenced by the cell as used.
 
void(* destroy )(UBuffer *buf)
 Free any memory or other resources the buffer uses.
 
void(* markBuf )(UThread *, UBuffer *buf)
 Responsible for marking other buffers referenced by this buffer as used.
 
void(* toShared )(UCell *cell)
 Change any buffer ids in the cell so that they reference the shared environment (negate the id).
 
void(* bind )(UThread *, UCell *cell, const UBindTarget *bt)
 Bind cell to target.
 

Detailed Description

The UDatatype struct holds methods for a specific class of data.

When implementing custom types, the unset.h methods can be used.

See also
USeriesType

Field Documentation

◆ compare

int(* UDatatype::compare) (UThread *, const UCell *a, const UCell *b, int test)

Perform a comparison between cells.

If the test is UR_COMPARE_SAME, then the type of cells a & b are guaranteed to be the same by the caller. Otherwise, one of the cells might not be of the datatype for this compare method.

When the test is UR_COMPARE_ORDER or UR_COMPARE_ORDER_CASE, then the method should return 1, 0, or -1, if cell a is greater than, equal to, or lesser than cell b.

The method should only check for datatypes with a lesser or equal ur_type(), as the caller will use the compare method for the higher ordered type.

Parameters
aFirst cell.
bSecond cell.
testType of comparison to do.
Returns
Non-zero if the camparison is true.

◆ convert

int(* UDatatype::convert) (UThread *, const UCell *from, UCell *res)

Convert data to a new instance of the type.

From and res are guaranteed to point to different cells.

Convert should perform a shallow copy on any complex types which can be nested.

Parameters
fromValue to convert.
resCell for new instance.
Returns
UR_OK/UR_THROW

◆ copy

void(* UDatatype::copy) (UThread *, const UCell *from, UCell *res)

Make a clone of an existing value.

From and res are guaranteed to point to different cells.

Parameters
fromValue to copy.
resCell for new instance.

◆ make

int(* UDatatype::make) (UThread *, const UCell *from, UCell *res)

Make a new instance of the type.

From and res are guaranteed to point to different cells.

Make should perform a shallow copy on any complex types which can be nested.

Parameters
fromValue which describes the new instance.
resCell for new instance.
Returns
UR_OK/UR_THROW

◆ mark

void(* UDatatype::mark) (UThread *, UCell *cell)

Responsible for marking any buffers referenced by the cell as used.

Use ur_markBuffer().

◆ operate

int(* UDatatype::operate) (UThread *, const UCell *, const UCell *, UCell *res, int)

Perform an operation on two cells.

The method should only check for datatypes with a lesser or equal ur_type(), as the caller will use the operate method for the higher ordered type.

Parameters
aFirst cell.
bSecond cell.
resResult cell.
opType of operation to do.
Returns
UR_OK/UR_THROW

◆ recycle

void(* UDatatype::recycle) (UThread *, int phase)

Performs thread global garbage collection duties for the datatype.

This is called twice from ur_recycle(), first with UR_RECYCLE_MARK, then with UR_RECYCLE_SWEEP.

◆ select

const UCell *(* UDatatype::select) (UThread *, const UCell *, const UCell *sel, UCell *tmp)

Get the value which a path node references.

If the selector is invalid, call ur_error() and return 0.

Parameters
cellCell of this datatype.
selSelector value.
tmpStorage for result (if needed). If used, then return tmp.
Returns
Pointer to result cell or 0 if an error is thrown.

◆ toString

void(* UDatatype::toString) (UThread *, const UCell *cell, UBuffer *str, int depth)

Convert cell to its string data representation.

Parameters
cellCell of this datatype.
strString buffer to append to.
depthIndentation depth.

◆ toText

void(* UDatatype::toText) (UThread *, const UCell *cell, UBuffer *str, int depth)

Convert cell to its string textual representation.

Parameters
cellCell of this datatype.
strString buffer to append to.
depthIndentation depth.

The documentation for this struct was generated from the following files: