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. |
When implementing custom types, the unset.h methods can be used.
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.
from | Value which describes the new instance. | |
res | Cell for new instance. |
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.
from | Value to convert. | |
res | Cell for new instance. |
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.
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.
a | First cell. | |
b | Second cell. | |
test | Type of comparison to do. |
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.
a | First cell. | |
b | Second cell. | |
res | Result cell. | |
op | Type of operation to do. |
Get the value which a path node references.
If the selector is invalid, call ur_error() and return 0.
cell | Cell of this datatype. | |
sel | Selector value. | |
tmp | Storage for result (if needed). If used, then return tmp. |
void(* UDatatype::toString)(UThread *, const UCell *cell, UBuffer *str, int depth) |
Convert cell to its string data representation.
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.
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().