Apps     Components     Interfaces     All Files     Source Tree     source: tos.lib.VM.interfaces.BombillaBuffer.nc

Interface: BombillaBuffer

Interface for accessing/modifying Bombilla data buffers.

Components providing this interface:
tos.lib.VM.components.BBuffer
tos.lib.VM.components.BBufferProxy

Components requiring this interface:
tos.lib.VM.opcodes.OPaddM
tos.lib.VM.opcodes.OPbclearM
tos.lib.VM.opcodes.OPbgetM
tos.lib.VM.opcodes.OPbheadM
tos.lib.VM.opcodes.OPbsortaM
tos.lib.VM.opcodes.OPbsortdM
tos.lib.VM.opcodes.OPbtailM
tos.lib.VM.opcodes.OPbyankM

Commands

Commands - Details

clear

result_t clear(BombillaContext *context, BombillaDataBuffer *buf)

Clear out a data buffer to be untyped and size zero.

Parameters:

context - The context cleaning out the buffer.

buf - The buffer to clear.

Returns: SUCCESS if the buffer was cleared, FAIL otherwise.

checkAndSetTypes

result_t checkAndSetTypes(BombillaContext *context, BombillaDataBuffer *buffer, BombillaStackVariable *var)

Check that a variable can be inserted into a buffer. If the buffer had no type, set it to the type of the variable so it can be inserted.

Parameters:

context - The context checking the types.

buf - The buffer to check.

var - The variable whose type to check.

Returns: SUCCESS if the variable can be inserted, FAIL otherwise.

append

result_t append(BombillaContext *context, BombillaDataBuffer *buffer, BombillaStackVariable *var)

Append a variable to a buffer. The buffer must be of the same type as the variable.

Parameters:

context - The context performing the append.

buf - The buffer to append to.

var - The variable to append.

Returns: SUCCESS if the variable was appended, FAIL otherwise.

prepend

result_t prepend(BombillaContext *context, BombillaDataBuffer *buffer, BombillaStackVariable *var)

Prepend a variable to a buffer. The buffer must be of the same type as the variable.

Parameters:

context - The context performing the prepend.

buf - The buffer to prepend to.

var - The variable to prepend.

Returns: SUCCESS if the variable was prepended, FAIL otherwise.

concatenate

uint8_t concatenate(BombillaContext *context, BombillaDataBuffer *dest, BombillaDataBuffer *src)

Concatenate one buffer onto the end of another. An element of the buffer concatenated-from must pass checkAndSetTypes() on the buffer to be concatenated-to. Elements are removed from the beginning of the src buffer.

Parameters:

context - The context performing the concatenation.

dest - The buffer to concatenate into.

src - The buffer to concatenate from.

Returns: The number of elements concatenated.

get

result_t get(BombillaContext *context, BombillaDataBuffer *buffer, uint8_t bufferIndex, BombillaStackVariable *dest)

Copy the nth element of a buffer into a supplied stack variable. Does not remove the element.

Parameters:

context - The context performing the get.

buffer - The buffer to get from.

bufferIndex - Which element to get.

dest - The variable to fill in with the element.

Returns: SUCCESS if element was successfully copied, FAIL otherwise.

yank

result_t yank(BombillaContext *context, BombillaDataBuffer *buffer, uint8_t bufferIndex, BombillaStackVariable *dest)

Copy the nth element of a buffer into a supplied stack variable. Removes the element.

Parameters:

context - The context performing the yank.

buffer - The buffer to yank from.

bufferIndex - Which element to yank out.

dest - The variable to fill in with the element.

Returns: SUCCESS if element was successfully copied and yanked out, FAIL otherwise.

sortAscending

result_t sortAscending(BombillaContext *context, BombillaDataBuffer *buffer)

Sort the elements of a buffer in ascending order. Element 0 of the buffer will be the lowest.

Parameters:

context - The context performing the sort.

buffer - The buffer to sort.

Returns: SUCCESS if the buffer was successfully sorted, FAIL otherwise.

sortDescending

result_t sortDescending(BombillaContext *context, BombillaDataBuffer *buffer)

Sort the elements of a buffer in descending order. Element 0 of the buffer will be the highest.

Parameters:

context - The context performing the sort.

buffer - The buffer to sort.

Returns: SUCCESS if the buffer was successfully sorted, FAIL otherwise.