Boron 0.1.0

Datatype Block
[Urlan Datatype System]

Blocks are a series of UCells. More...

Defines

#define ur_blkFree   ur_arrFree
 A block is a simple array.

Functions

UIndex ur_makeBlock (UThread *ut, int size)
 Generate a single block of type UT_BLOCK.
UBufferur_makeBlockCell (UThread *ut, int type, int size, UCell *cell)
 Generate a single block and set cell to reference it.
void ur_blkInit (UBuffer *buf, int type, int size)
 Initialize block buffer.
UCellur_blkAppendNew (UBuffer *buf, int type)
 Add cell to end of block.
void ur_blkAppendCells (UBuffer *buf, const UCell *cells, int count)
 Append cells to block.
void ur_blkInsert (UBuffer *buf, UIndex it, const UCell *cells, int count)
 Insert cells into block.
void ur_blkPush (UBuffer *buf, const UCell *cell)
 Copy cell to end of block.
UCellur_blkPop (UBuffer *buf)
 Remove cell from end of block.
void ur_blkSlice (UThread *ut, UBlockIter *bi, const UCell *cell)
 Set UBlockIter to block slice.
int ur_blkSliceM (UThread *ut, UBlockIterM *bi, const UCell *cell)
 Set UBlockIterM to block slice.
UIndex ur_blkClone (UThread *ut, UIndex blkN)
 Make deep copy of block.

Detailed Description

Blocks are a series of UCells.


Function Documentation

void ur_blkAppendCells ( UBuffer buf,
const UCell cells,
int  count 
)

Append cells to block.

Parameters:
buf Initialized block buffer.
cells Cells to copy.
count Number of cells to copy.

UCell* ur_blkAppendNew ( UBuffer buf,
int  type 
)

Add cell to end of block.

Returns:
Pointer to new cell. Only the cell id is initialized; other members are unset.

UIndex ur_blkClone ( UThread ut,
UIndex  blkN 
)

Make deep copy of block.

Parameters:
blkN Buffer id of block to clone.
Returns:
Buffer id of new block.

void ur_blkInit ( UBuffer buf,
int  type,
int  size 
)

Initialize block buffer.

Parameters:
type Buffer type (Normally UT_BLOCK).
size Number of cells to reserve.

void ur_blkInsert ( UBuffer buf,
UIndex  it,
const UCell cells,
int  count 
)

Insert cells into block.

This performs a memcpy, so the source cells must not overlap the buf cells.

Parameters:
buf Initialized block buffer.
it Position in buf.
cells Cells to copy.
count Number of cells to copy.

UCell* ur_blkPop ( UBuffer buf  ) 

Remove cell from end of block.

Returns:
Pointer to what was the last cell, or zero if block is empty.

void ur_blkSlice ( UThread ut,
UBlockIter *  bi,
const UCell cell 
)

Set UBlockIter to block slice.

Parameters:
bi Iterator struct to fill.
cell Pointer to a valid block cell.
Returns:
Initializes bi. If slice is empty then bi->it and bi->end are set to zero.

int ur_blkSliceM ( UThread ut,
UBlockIterM *  bi,
const UCell cell 
)

Set UBlockIterM to block slice.

If cell references a block in shared storage then an error is generated and UR_THROW is returned. Otherwise, bi is initialized. If the slice is empty then bi->it and bi->end are set to zero.

Parameters:
bi Iterator struct to fill.
cell Pointer to a valid block cell.
Returns:
UR_OK/UR_THROW
Examples:
calculator.c.

UIndex ur_makeBlock ( UThread ut,
int  size 
)

Generate a single block of type UT_BLOCK.

If you need multiple buffers then ur_genBuffers() should be used.

The caller must create a UCell for this block in a held block before the next ur_recycle() or else it will be garbage collected.

Parameters:
size Number of cells to reserve.
Returns:
Buffer id of block.

UBuffer* ur_makeBlockCell ( UThread ut,
int  type,
int  size,
UCell cell 
)

Generate a single block and set cell to reference it.

If you need multiple buffers then ur_genBuffers() should be used.

Parameters:
type Type (UT_BLOCK, UT_PAREN, etc.).
size Number of cells to reserve.
cell Cell to initialize.
Returns:
Pointer to block buffer.


Generated on 27 Jan 2012 by Doxygen 1.5.1