Boron 0.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

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:
from Value which describes the new instance.
res Cell for new instance.
Returns:
UR_OK/UR_THROW

void(* 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:
from Value to convert.
res Cell for new instance.
Returns:
UR_OK/UR_THROW

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:
from Value to copy.
res Cell for new instance.

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:
a First cell.
b Second cell.
test Type of comparison to do.
Returns:
Non-zero if the camparison is true.

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

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:
a First cell.
b Second cell.
res Result cell.
op Type of operation to do.
Returns:
UR_OK/UR_THROW

const UCell *(* UDatatype::select)(UThread *, const UCell *cell, 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:
cell Cell of this datatype.
sel Selector value.
tmp Storage for result (if needed). If used, then return tmp.
Returns:
Pointer to result cell or 0 if an error is thrown.

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

Convert cell to its string data representation.

Parameters:
cell Cell of this datatype.
str String buffer to append to.
depth Indentation depth.

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

Convert cell to its string textual representation.

Parameters:
cell Cell of this datatype.
str String buffer to append to.
depth Indentation depth.

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.

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

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

Use ur_markBuffer().


The documentation for this struct was generated from the following files:
Generated on 27 Jan 2012 by Doxygen 1.5.1