Boron 2.1.0
Data Structures | Macros | Enumerations | Functions
urlan.h File Reference

The Urlan programmer interface. More...

#include <stdint.h>

Go to the source code of this file.

Data Structures

struct  UCellId
 Basic type identification. More...
 
struct  UCellDatatype
 UCell structure for datatype! type. More...
 
struct  UCellNumber
 UCell structure for number types. More...
 
struct  UCellCoord
 UCell structure for coord type. More...
 
struct  UCellVec3
 UCell structure for vec3! type. More...
 
struct  UCellWord
 UCell structure for word types. More...
 
struct  UCellSeries
 UCell structure for series types. More...
 
struct  UCellError
 UCell structure for error! type. More...
 
union  UCell
 A cell holds a single value of a simple type or a reference (often to a UBuffer) for a complex type. More...
 
struct  UBuffer
 The UBuffer struct holds information about a resource, usually a chuck of memory. More...
 
struct  UThread
 The UThread struct stores the data specific to a thread of execution. More...
 
struct  USeriesIter
 Iterator for const series of any type. More...
 
struct  UBlockIt
 Iterator for const UCell array. More...
 
struct  UBindTarget
 Holds information for binding functions. More...
 
struct  UDatatype
 The UDatatype struct holds methods for a specific class of data. More...
 
struct  USeriesType
 The USeriesType struct holds extra methods for series datatypes. More...
 
struct  UEnvParameters
 The UEnvParameters struct allows the user to override default buffer and structure sizes. More...
 

Macros

#define UR_STATIC   0x80
 This UBuffer::flags bit is set when the UBuffer::ptr points to memory outside of the Urlan datatype system and must not be freed. More...
 
#define ur_strFree   ur_arrFree
 A string is a simple array.
 
#define ur_blkFree   ur_arrFree
 A block is a simple array.
 
#define ur_ctxCell(c, n)   ((c)->ptr.cell + (n))
 Get pointer of UCell in context by index.
 
#define ur_avail(buf)   (buf)->ptr.i32[-1]
 Returns the capacity of a UBuffer that is known to have been allocated. More...
 
#define ur_testAvail(buf)   (buf->ptr.v ? ur_avail(buf) : 0)
 Returns the capacity of a UBuffer. More...
 
#define ur_type(c)   (c)->id.type
 Return UrlanDataType of cell.
 
#define ur_setId(c, t)   *((uint32_t*) (c)) = t
 Set type and initialize the other 24 bits of UCellId to zero.
 
#define ur_datatype(c)   (c)->datatype.n
 Access the UrlanDataType that a UCellDatatype represents.
 
#define ur_isShared(n)   (n < 0)
 True if buffer number refers to a buffer in the shared environment.
 
#define ur_isSliced(c)   ((c)->series.end > -1)
 True if the end member of a series cell is set.
 
#define ur_pop(ut)   --(ut)->stack.used
 Decrement stack.used. More...
 
#define ur_hold(n)   ur_holdBuffer(ut,n)
 Convenience macro for ur_holdBuffer().
 
#define ur_release(h)   ur_releaseBuffer(ut,h)
 Convenience macro for ur_releaseBuffer().
 
#define ur_buffer(n)   (ut->dataStore.ptr.buf + (n))
 Macro to get buffer known to be in thread dataStore.
 
#define ur_bufferE(n)   ur_bufferEnv(ut,n)
 Convenience macro for ur_bufferEnv().
 
#define ur_bufferSer(c)   ur_bufferSeries(ut,c)
 Convenience macro for ur_bufferSeries().
 
#define ur_bufferSerM(c)   ur_bufferSeriesM(ut,c)
 Convenience macro for ur_bufferSeriesM().
 
#define ur_foreach(bi)   for(; bi.it != bi.end; ++bi.it)
 Loop over all members of an iterator struct. More...
 
#define ur_cstr(strC, bin)    ur_cstring(ur_bufferSer(strC), bin, strC->series.it, strC->series.end)
 Make null terminated UTF-8 string in binary buffer. More...
 

Enumerations

enum  UrlanDataType { }
 
enum  UrlanWordBindings {
  UR_BIND_UNBOUND = 0 , UR_BIND_THREAD , UR_BIND_ENV , UR_BIND_STACK ,
  UR_BIND_SELF , UR_BIND_SECURE , UR_BIND_USER
}
 
enum  UStatus { UR_THROW = 0 , UR_OK = 1 }
 
enum  UrlanErrorType {
  UR_ERR_TYPE , UR_ERR_SCRIPT , UR_ERR_SYNTAX , UR_ERR_ACCESS ,
  UR_ERR_INTERNAL , UR_ERR_COUNT
}
 
enum  UThreadMethod { UR_THREAD_INIT , UR_THREAD_FREE , UR_THREAD_FREEZE }
 
enum  UrlanRecyclePhase { UR_RECYCLE_MARK , UR_RECYCLE_SWEEP }
 

Functions

UEnvParametersur_envParam (UEnvParameters *par)
 Initialize UEnvParameters structure to default values.
 
UThreadur_makeEnv (const UEnvParameters *)
 Allocate UEnv and initial UThread. More...
 
void ur_freeEnv (UThread *)
 Free environment and the initial thread. More...
 
void ur_freezeEnv (UThread *)
 Move the startup thread dataStore to the shared environment. More...
 
UThreadur_makeThread (const UThread *)
 Create a new thread. More...
 
int ur_destroyThread (UThread *)
 Free memory used by UThread. More...
 
int ur_datatypeCount (UThread *)
 Get number of datatypes installed in the environment. More...
 
UAtom ur_intern (UThread *, const char *name, int len)
 Add a single atom to the shared environment. More...
 
UAtom ur_internAtom (UThread *, const char *it, const char *end)
 Add a single atom to the shared environment. More...
 
UAtom * ur_internAtoms (UThread *, const char *words, UAtom *atoms)
 Add atoms to the shared environment. More...
 
const char * ur_atomCStr (UThread *, UAtom atom)
 Get name of atom. More...
 
void ur_atomsSort (UAtomEntry *entries, int low, int high)
 Sort UAtomEntry table in ascending atom value order. More...
 
int ur_atomsSearch (const UAtomEntry *entries, int count, UAtom atom)
 Find an atom in a UAtomEntry table using a binary search. More...
 
UBufferur_genBuffers (UThread *, int count, UIndex *index)
 Generate new buffers in dataStore. More...
 
UBufferur_generate (UThread *, int count, UIndex *index, const uint8_t *)
 Generate and initialize buffers of given types. More...
 
void ur_destroyBuffer (UThread *, UBuffer *)
 Destroy buffer in dataStore. More...
 
UIndex ur_holdBuffer (UThread *, UIndex bufN)
 Keeps buffer in thread dataStore from being garbage collected by ur_recycle(). More...
 
void ur_releaseBuffer (UThread *, UIndex hold)
 Enables garbage collection of dataStore buffer which was held by ur_holdBuffer().
 
void ur_recycle (UThread *)
 Perform garbage collection on thread dataStore. More...
 
int ur_markBuffer (UThread *, UIndex bufN)
 Makes sure the buffer is marked as used. More...
 
UCellur_push (UThread *, int type)
 Set id of cell on top of stack and increment stack.used. More...
 
UCellur_pushCell (UThread *, const UCell *)
 Copy cell to top of stack and increment stack.used. More...
 
UStatus ur_error (UThread *, int errorType, const char *fmt,...)
 Create error! exception. More...
 
UBufferur_threadContext (UThread *)
 Get thread global context. More...
 
UBufferur_envContext (UThread *)
 Get shared global context. More...
 
void ur_appendTrace (UThread *, UIndex blkN, UIndex it)
 Append block position to the current exception error! trace. More...
 
UIndex ur_tokenize (UThread *, const char *it, const char *end, UCell *res)
 Convert a UTF-8 data string into a block. More...
 
UStatus ur_tokenizeB (UThread *, UIndex blkN, int inputEncoding, const uint8_t *start, const uint8_t *end)
 Parse UTF-8 or Latin1 data into block. More...
 
UStatus ur_serialize (UThread *, UIndex blkN, UCell *res)
 Serialize block. More...
 
UStatus ur_unserialize (UThread *, const uint8_t *start, const uint8_t *end, UCell *res)
 Unserialize binary. More...
 
void ur_toStr (UThread *, const UCell *cell, UBuffer *str, int depth)
 Append data representation of cell to a string. More...
 
void ur_toText (UThread *, const UCell *cell, UBuffer *str)
 Append textual representation of cell to a string. More...
 
const UCellur_wordCell (UThread *, const UCell *cell)
 Get word value for read-only operations. More...
 
UCellur_wordCellM (UThread *, const UCell *cell)
 Get modifiable word value. More...
 
UStatus ur_setWord (UThread *, const UCell *wordCell, const UCell *src)
 Set word. More...
 
const UBufferur_bufferEnv (UThread *, UIndex n)
 Get buffer from either the thread dataStore or environment sharedStore. More...
 
const UBufferur_bufferSeries (const UThread *, const UCell *cell)
 Get series buffer. More...
 
UBufferur_bufferSeriesM (UThread *, const UCell *cell)
 Get modifiable series buffer. More...
 
void ur_seriesSlice (const UThread *, USeriesIter *si, const UCell *cell)
 Set USeriesIter to series slice. More...
 
UStatus ur_seriesSliceM (UThread *, USeriesIterM *si, const UCell *cell)
 Set USeriesIterM to modifiable series slice. More...
 
const UBufferur_blockIt (const UThread *ut, UBlockIt *bi, const UCell *blkCell)
 Set UBlockIt to the start and end of a block slice. More...
 
void ur_bind (UThread *, UBuffer *blk, const UBuffer *ctx, int bindType)
 Bind block to context. More...
 
void ur_bindCells (UThread *, UCell *it, UCell *end, const UBindTarget *bt)
 Bind an array of cells to a target. More...
 
void ur_bindCopy (UThread *, const UBuffer *ctx, UCell *it, UCell *end)
 Recursively bind blocks to the bindings found in a context. More...
 
void ur_unbindCells (UThread *, UCell *it, UCell *end, int deep)
 Unbind all words in an array of cells. More...
 
void ur_infuse (UThread *, UCell *it, UCell *end, const UBuffer *ctx)
 Replace words in cells with their values from a context. More...
 
int ur_true (const UCell *cell)
 Check if a value is "true". More...
 
int ur_same (UThread *, const UCell *a, const UCell *b)
 
int ur_equal (UThread *, const UCell *a, const UCell *b)
 
int ur_equalCase (UThread *, const UCell *a, const UCell *b)
 Case-sensitive equality test. More...
 
int ur_compare (UThread *, const UCell *a, const UCell *b)
 
int ur_compareCase (UThread *, const UCell *a, const UCell *b)
 Case-sensitive ordering comparison. More...
 
void ur_makeDatatype (UCell *cell, int type)
 Initialize cell to be a UT_DATATYPE value of the given type.
 
int ur_isDatatype (const UCell *cell, const UCell *datatype)
 Test if cell is of a certain datatype. More...
 
void ur_datatypeAddType (UCell *cell, int type)
 Add type to multi-type UT_DATATYPE cell.
 
int ur_charLowercase (int c)
 Convert UCS2 character to lowercase.
 
int ur_charUppercase (int c)
 Convert UCS2 character to uppercase.
 
UIndex ur_makeBinary (UThread *, int size)
 Generate and initialize a single binary buffer. More...
 
UBufferur_makeBinaryCell (UThread *, int size, UCell *cell)
 Generate a single binary and set cell to reference it. More...
 
void ur_binInit (UBuffer *, int size)
 Initialize buffer to type UT_BINARY. More...
 
void ur_binReserve (UBuffer *, int size)
 Allocates enough memory to hold size bytes. More...
 
void ur_binExpand (UBuffer *, int index, int count)
 Create space in the binary for count bytes starting at index. More...
 
void ur_binErase (UBuffer *, int start, int count)
 Remove bytes from the binary. More...
 
void ur_binAppendData (UBuffer *, const uint8_t *data, int len)
 Append data to binary buffer. More...
 
void ur_binAppendArray (UBuffer *, const USeriesIter *si)
 Append array slice to binary buffer. More...
 
const char * ur_binAppendBase (UBuffer *buf, const char *it, const char *end, enum UrlanBinaryEncoding enc)
 Append encoded ASCII string to binary buffer. More...
 
void ur_binFree (UBuffer *)
 Free binary data. More...
 
void ur_binSlice (UThread *, UBinaryIter *, const UCell *cell)
 Set UBinaryIter to binary slice. More...
 
UStatus ur_binSliceM (UThread *, UBinaryIterM *, const UCell *cell)
 Set UBinaryIterM to binary slice. More...
 
void ur_binToStr (UBuffer *, int encoding)
 Convert binary buffer to string buffer. More...
 
UIndex ur_makeString (UThread *, int enc, int size)
 Generate and initialize a single string buffer. More...
 
UBufferur_makeStringCell (UThread *, int enc, int size, UCell *cell)
 Generate a single string and set cell to reference it. More...
 
UIndex ur_makeStringLatin1 (UThread *, const uint8_t *it, const uint8_t *end)
 Generate and initialize a single string buffer from memory holding a Latin-1 string. More...
 
UIndex ur_makeStringUtf8 (UThread *, const uint8_t *it, const uint8_t *end)
 Generate and initialize a single string buffer from memory holding a UTF-8 string. More...
 
void ur_strInit (UBuffer *, int enc, int size)
 Initialize buffer to type UT_STRING. More...
 
void ur_strInitUtf8 (UBuffer *, const uint8_t *it, const uint8_t *end)
 Initialize a single string buffer from memory holding a UTF-8 string. More...
 
void ur_strAppendCStr (UBuffer *, const char *)
 Append a null-terminated UTF-8 string to a string buffer.
 
void ur_strAppendChar (UBuffer *, int)
 Append a single UCS2 character to a string.
 
void ur_strAppendInt (UBuffer *, int32_t)
 Append an integer to a string.
 
void ur_strAppendInt64 (UBuffer *, int64_t)
 Append an 64-bit integer to a string.
 
void ur_strAppendHex (UBuffer *, uint32_t n, uint32_t hi)
 Append a hexidecimal integer to a string.
 
void ur_strAppendDouble (UBuffer *, double)
 Append a double to a string.
 
void ur_strAppendFloat (UBuffer *, float)
 Append a float to a string. More...
 
void ur_strAppendIndent (UBuffer *, int depth)
 Append tabs to a string. More...
 
void ur_strAppend (UBuffer *, const UBuffer *strB, UIndex itB, UIndex endB)
 Append another string buffer to this string. More...
 
void ur_strAppendBinary (UBuffer *, const uint8_t *it, const uint8_t *end, enum UrlanBinaryEncoding enc)
 Append binary data as text of the specified encoding.
 
void ur_strTermNull (UBuffer *)
 Terminate with null character so buffer can be used as a C string. More...
 
int ur_strIsAscii (const UBuffer *)
 Test if all characters are ASCII. More...
 
void ur_strFlatten (UBuffer *)
 Convert a UTF-8 or UCS-2 string buffer to Latin-1 if possible. More...
 
void ur_strLowercase (UBuffer *str, UIndex start, UIndex send)
 Convert characters of string slice to lowercase. More...
 
void ur_strUppercase (UBuffer *str, UIndex start, UIndex send)
 Convert characters of string slice to uppercase. More...
 
UIndex ur_strFindChar (const UBuffer *, UIndex, UIndex, int ch, int opt)
 Find the first instance of a character in a string. More...
 
UIndex ur_strFindChars (const UBuffer *, UIndex start, UIndex end, const uint8_t *charSet, int len)
 Find the first character of a set in a string. More...
 
UIndex ur_strFindCharsRev (const UBuffer *, UIndex start, UIndex end, const uint8_t *charSet, int len)
 Find the last character of a set in a string. More...
 
UIndex ur_strFind (const USeriesIter *, const USeriesIter *, int matchCase)
 Find string in another string or binary series. More...
 
UIndex ur_strFindRev (const USeriesIter *, const USeriesIter *, int matchCase)
 Find last string in another string or binary series. More...
 
UIndex ur_strMatch (const USeriesIter *, const USeriesIter *, int matchCase)
 Compare characters in two string or binary series. More...
 
int ur_strChar (const UBuffer *, UIndex pos)
 Return the character at a given position. More...
 
char * ur_cstring (const UBuffer *, UBuffer *bin, UIndex start, UIndex end)
 Make null terminated UTF-8 string in binary buffer. More...
 
UIndex ur_makeBlock (UThread *, int size)
 Generate a single block of type UT_BLOCK. More...
 
UBufferur_makeBlockCell (UThread *, int type, int size, UCell *cell)
 Generate a single block and set cell to reference it. More...
 
UIndex ur_blkClone (UThread *, UIndex blkN)
 Make deep copy of block. More...
 
void ur_blkInit (UBuffer *, int type, int size)
 Initialize block buffer. More...
 
UCellur_blkAppendNew (UBuffer *, int type)
 Add cell to end of block. More...
 
void ur_blkAppendCells (UBuffer *, const UCell *cells, int count)
 Append cells to block. More...
 
void ur_blkInsert (UBuffer *, UIndex it, const UCell *cells, int count)
 Insert cells into block. More...
 
void ur_blkPush (UBuffer *, const UCell *cell)
 Copy cell to end of block.
 
UCellur_blkPop (UBuffer *)
 Remove cell from end of block. More...
 
void ur_blkSlice (UThread *, UBlockIter *, const UCell *cell)
 Set UBlockIter to block slice. More...
 
UStatus ur_blkSliceM (UThread *, UBlockIterM *, const UCell *cell)
 Set UBlockIterM to block slice. More...
 
void ur_blkCollectType (UThread *, const UCell *blkCell, uint32_t typeMask, UBuffer *dest, int unique)
 Find all values of a certain type and append them to another block. More...
 
int ur_pathResolve (UThread *, UBlockIt *pi, UCell *tmp, UCell **lastCell)
 Get a pointer to the last value that a path! refers to. More...
 
int ur_pathCell (UThread *, const UCell *pc, UCell *res)
 Get the value which a path refers to. More...
 
UStatus ur_setPath (UThread *, const UCell *path, const UCell *src)
 Set path. More...
 
UIndex ur_makeContext (UThread *, int size)
 Generate and initialize a single context. More...
 
UBufferur_makeContextCell (UThread *, int size, UCell *cell)
 Generate a single context and set cell to reference it. More...
 
UBufferur_ctxClone (UThread *, const UBuffer *src, UCell *cell)
 Clone a new context and set cell to reference it. More...
 
UBufferur_ctxMirror (UThread *, const UBuffer *src, UCell *cell)
 Create a shallow copy of a context and set cell to reference the new context. More...
 
void ur_ctxInit (UBuffer *, int size)
 Initialize context buffer. More...
 
void ur_ctxReserve (UBuffer *, int size)
 Allocates enough memory to hold size words. More...
 
void ur_ctxFree (UBuffer *)
 Free context data. More...
 
UBufferur_ctxSort (UBuffer *)
 Sort the internal context search table so ur_ctxLookup() is faster. More...
 
void ur_ctxSetWords (UBuffer *, const UCell *it, const UCell *end)
 Add the set-word! values in a series of cells to the words in a context. More...
 
int ur_ctxAppendWord (UBuffer *, UAtom atom)
 Append word to context. More...
 
int ur_ctxAddWordI (UBuffer *, UAtom atom)
 Add word to context if it does not already exist. More...
 
UCellur_ctxAddWord (UBuffer *, UAtom atom)
 Similar to ur_ctxAddWordI(), but safely returns the cell pointer. More...
 
void ur_ctxWordAtoms (const UBuffer *, UAtom *atoms)
 Get word atoms in order. More...
 
int ur_ctxLookup (const UBuffer *, UAtom atom)
 Find word in context by atom. More...
 
const UBufferur_sortedContext (UThread *, const UCell *)
 Get context and make sure it is ready for ur_ctxLookup(). More...
 
UIndex ur_makeVector (UThread *, enum UrlanVectorType, int size)
 Generate a single vector buffer. More...
 
UBufferur_makeVectorCell (UThread *, enum UrlanVectorType, int size, UCell *)
 Generate a single vector and set cell to reference it. More...
 
void ur_arrInit (UBuffer *, int size, int count)
 Initialize array buffer. More...
 
void ur_arrReserve (UBuffer *, int count)
 Allocates enough memory to hold count elements. More...
 
void ur_arrExpand (UBuffer *, int index, int count)
 Create space in the array for count elements starting at index. More...
 
void ur_arrErase (UBuffer *, int start, int count)
 Remove elements from the array. More...
 
void ur_arrFree (UBuffer *)
 Free array data. More...
 
void ur_arrAppendInt32 (UBuffer *, int32_t)
 Append int32_t to array. More...
 
void ur_arrAppendFloat (UBuffer *, float)
 Append float to array. More...
 

Detailed Description

The Urlan programmer interface.

This is a C library which provides a garbage collected datatype system and data format which can be used for building domain specific languages.

Macro Definition Documentation

◆ ur_avail

#define ur_avail (   buf)    (buf)->ptr.i32[-1]

Returns the capacity of a UBuffer that is known to have been allocated.

This macro is quicker than ur_testAvail, but must not be used when the UBuffer::ptr is NULL.

◆ UR_STATIC

#define UR_STATIC   0x80

This UBuffer::flags bit is set when the UBuffer::ptr points to memory outside of the Urlan datatype system and must not be freed.

It indicates that the UBuffer::used member should not be modifed and that the ur_avail & ur_testAvail macros must not be used on the buffer.

◆ ur_testAvail

#define ur_testAvail (   buf)    (buf->ptr.v ? ur_avail(buf) : 0)

Returns the capacity of a UBuffer.

Unlike ur_avail, this can be safely used even when the buffer memory has not been allocated.

Enumeration Type Documentation

◆ UrlanDataType

Enumerator
UT_TYPEMASK 

Used in UCellDatatype to declare a multi-type datatype!.

◆ UrlanErrorType

Enumerator
UR_ERR_TYPE 

Invalid argument/parameter datatype.

UR_ERR_SCRIPT 

General script evaluation error.

UR_ERR_SYNTAX 

Syntax error.

UR_ERR_ACCESS 

Problem accessing external resources.

UR_ERR_INTERNAL 

Fatal internal problem.

◆ UrlanRecyclePhase

Enumerator
UR_RECYCLE_MARK 

Phase passed to UDatatype::recycle.

UR_RECYCLE_SWEEP 

Phase passed to UDatatype::recycle.

◆ UrlanWordBindings

Enumerator
UR_BIND_UNBOUND 

ur_setId() zeros binding so this is default.

UR_BIND_THREAD 

Bound to buffer in thread dataStore.

UR_BIND_ENV 

Bound to buffer in shared env dataStore.

UR_BIND_STACK 

Bound to thread stack.

UR_BIND_SELF 

Evaluate to bound context rather than value.

UR_BIND_SECURE 

As UR_BIND_THREAD but unbind if not in context.

UR_BIND_USER 

Start of user defined bindings.

◆ UStatus

enum UStatus
Enumerator
UR_THROW 

Returned to indicate an evaluation exception occured.

This is guaranteed to always be zero.

UR_OK 

Returned to indicate successful evaluation/operation.

This is guaranteed to always be one.

◆ UThreadMethod

Enumerator
UR_THREAD_INIT 

The new thread must be initialized.

UR_THREAD_FREE 

The thread is being freed.

UR_THREAD_FREEZE 

The thread dataStore is being moved to the shared environment.

Function Documentation

◆ ur_arrAppendFloat()

void ur_arrAppendFloat ( UBuffer buf,
float  n 
)

Append float to array.

Parameters
bufArray buffer with elemSize of 4.
nNumber to append.

◆ ur_arrAppendInt32()

void ur_arrAppendInt32 ( UBuffer buf,
int32_t  n 
)

Append int32_t to array.

Parameters
bufArray buffer with elemSize of 4.
nNumber to append.

◆ ur_arrErase()

void ur_arrErase ( UBuffer buf,
int  start,
int  count 
)

Remove elements from the array.

Parameters
bufInitialized array buffer.
startStart index of erase.
countNumber of elements to remove.

◆ ur_arrExpand()

void ur_arrExpand ( UBuffer buf,
int  index,
int  count 
)

Create space in the array for count elements starting at index.

The memory in the new space is uninitialized.

Parameters
bufInitialized array buffer.
indexPosition to expand at.
countNumber of elements to expand.

◆ ur_arrFree()

void ur_arrFree ( UBuffer buf)

Free array data.

buf->ptr and buf->used are set to zero.

◆ ur_arrInit()

void ur_arrInit ( UBuffer buf,
int  size,
int  count 
)

Initialize array buffer.

The buf type, form, flags, and used members are set to zero.

Parameters
bufUninitialized buffer.
sizeElement byte size. Must be less than 256.
countNumber of elements to allocate.

◆ ur_arrReserve()

void ur_arrReserve ( UBuffer buf,
int  count 
)

Allocates enough memory to hold count elements.

buf->used is not changed.

Parameters
bufInitialized array buffer.
countTotal number of elements.

◆ ur_isDatatype()

int ur_isDatatype ( const UCell cell,
const UCell datatype 
)

Test if cell is of a certain datatype.

Parameters
cellCell to test.
datatypeValid cell of type UT_DATATYPE.
Returns
Non-zero if cell type matches datatype.

◆ ur_makeVector()

UIndex ur_makeVector ( UThread ut,
enum UrlanVectorType  type,
int  size 
)

Generate a single vector buffer.

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
typeElement type (UR_VEC_U16, UR_VEC_I32, UR_VEC_F32, etc.).
sizeNumber of elements to reserve.
Returns
Buffer id of block.

◆ ur_makeVectorCell()

UBuffer * ur_makeVectorCell ( UThread ut,
enum UrlanVectorType  type,
int  size,
UCell cell 
)

Generate a single vector and set cell to reference it.

Parameters
typeElement type (UR_VEC_U16, UR_VEC_I32, UR_VEC_F32, etc.).
sizeNumber of elements to reserve.
cellCell to initialize.
Returns
Pointer to vector buffer.

◆ ur_markBuffer()

int ur_markBuffer ( UThread ut,
UIndex  bufN 
)

Makes sure the buffer is marked as used.

If the buffer had not already been marked as used, then non-zero is returned, and the caller is expected to invoke the UDatatype::markBuf method.

Note
This may only be called from inside a UDatatype::mark or UDatatype::markBuf method.
Parameters
bufNBuffer index into thread dataStore.
Returns
Zero if already marked as used.

◆ ur_recycle()

void ur_recycle ( UThread ut)

Perform garbage collection on thread dataStore.

This is a precise, tracing, mark-sweep collector. If starts with held buffers and the datatypes trace any buffers they reference.

Any UBuffer pointers to the thread dataStore must be considered invalid after this call. Note that while the buffer structures may move, the data that they point to (the UBuffer::ptr member) will not change.

◆ ur_serialize()

UStatus ur_serialize ( UThread ut,
UIndex  blkN,
UCell res 
)

Serialize block.

Parameters
blkNIndex to valid block buffer.
resCell to be set to new output binary.
Returns
UR_OK/UR_THROW

◆ ur_unserialize()

UStatus ur_unserialize ( UThread ut,
const uint8_t *  start,
const uint8_t *  end,
UCell res 
)

Unserialize binary.

Parameters
startPointer to serialized binary.
endPointer to end of binary.
resCell to be set to new output block.
Returns
UR_OK/UR_THROW