Boron 2.1.0
urlan.h
Go to the documentation of this file.
1#ifndef URLAN_H
2#define URLAN_H
3/*
4 Copyright 2009-2015,2019-2024 Karl Robillard
5
6 This file is part of the Urlan datatype system.
7
8 Urlan is free software: you can redistribute it and/or modify
9 it under the terms of the GNU Lesser General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
12
13 Urlan is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU Lesser General Public License for more details.
17
18 You should have received a copy of the GNU Lesser General Public License
19 along with Urlan. If not, see <http://www.gnu.org/licenses/>.
20*/
21
22
23#ifdef __sun__
24#include <inttypes.h>
25#ifdef _BIG_ENDIAN
26#define __BIG_ENDIAN__
27#endif
28#else
29#include <stdint.h>
30#endif
31
32
33#define UR_VERSION_STR "2.96.0"
34#define UR_VERSION 0x0209600
35
36
38{
39 UT_UNSET,
40 UT_DATATYPE,
41 UT_NONE,
42 UT_LOGIC,
43 UT_CHAR,
44 UT_INT,
45 UT_DOUBLE,
46 UT_BIGNUM,
47 UT_TIME,
48 UT_DATE,
49 UT_COORD,
50 UT_VEC3,
51 UT_TIMECODE,
52 UT_WORD, //--- The following values reference buffers.
53 UT_LITWORD,
54 UT_SETWORD,
55 UT_GETWORD,
56 UT_OPTION,
57 UT_BINARY, //--- Series values
58 UT_BITSET,
59 UT_STRING,
60 UT_FILE,
61 UT_VECTOR,
62 UT_BLOCK,
63 UT_PAREN,
64 UT_PATH, //--- Other non-series values
65 UT_LITPATH,
66 UT_SETPATH,
67 UT_CONTEXT,
68 UT_HASHMAP,
69 UT_ERROR,
70
71 UT_BI_COUNT,
72 UT_MAX = 64,
74 UT_REFERENCE_BUF = UT_WORD
75};
76
77
78/* Cell flags */
79
80#define UR_FLAG_INT_HEX 0x01
81#define UR_FLAG_TIMECODE_DF 0x01
82#define UR_FLAG_SOL 0x80
83
84
95
96
97enum UrlanBinaryEncoding
98{
99 UR_BENC_16,
100 UR_BENC_2,
101 UR_BENC_64,
102 UR_BENC_COUNT
103};
104
105
106enum UrlanStringEncoding
107{
108 UR_ENC_LATIN1,
109 UR_ENC_UTF8,
110 UR_ENC_UCS2,
111 UR_ENC_COUNT
112};
113
114
115typedef enum
116{
119}
120UStatus;
121
122
132
133
134enum UrlanVectorType
135{
136 UR_VEC_I16 = 66, /* Currently the same as atoms. */
137 UR_VEC_U16,
138 UR_VEC_I32,
139 UR_VEC_U32,
140 UR_VEC_F32,
141 UR_VEC_F64
142};
143
144
145#define UR_INVALID_BUF 0
146#define UR_INVALID_HOLD -1
147#define UR_INVALID_ATOM 0xffff
148
149
150typedef int32_t UIndex;
151typedef uint16_t UAtom;
152
153
154typedef struct
155{
156 uint8_t type;
157 uint8_t flags;
158 uint16_t ext;
159}
160UCellId;
161
162
163typedef struct
164{
165 uint8_t type;
166 uint8_t flags;
167 uint8_t n;
168 uint8_t _pad0;
169 uint32_t mask0; /* LIMIT: Maximum of 96 datatypes. */
170 uint32_t mask1;
171 uint32_t mask2;
172}
174
175
176typedef struct
177{
179 int32_t i32;
180 union {
181 int64_t i64;
182 double d;
183 } eb;
184}
186
187
188#define UR_COORD_MAX 6
189
190typedef struct
191{
192 uint8_t type;
193 uint8_t flags;
194 uint16_t len;
195 int16_t n[ UR_COORD_MAX ];
196}
198
199
200typedef struct
201{
203 float xyz[3];
204}
206
207
208#define UR_SELECT_ATOM 1
209#define UR_SELECT_INT 2
210
211typedef struct
212{
213 uint8_t type;
214 uint8_t flags;
215 uint8_t binding;
216 uint8_t selType;
217 UIndex ctx; /* Same location as UCellSeries buf. */
218 uint16_t index; /* LIMIT: Words per context. */
219 UAtom atom;
220 UAtom sel[2];
221}
223
224
225typedef struct
226{
228 UIndex buf; /* Buffer index. Same location as UCellWord ctx. */
229 UIndex it; /* Element iterator, slice start */
230 UIndex end; /* Slice end */
231}
233
234
235typedef struct
236{
237 uint8_t type;
238 uint8_t flags;
239 uint16_t exType;
242 UIndex _pad0;
243}
245
246
260UCell;
261
262
263typedef struct UBuffer UBuffer;
264
266{
267 uint8_t type;
268 uint8_t elemSize; // For array buffers.
269 uint8_t form; // Encoding, etc.
270 uint8_t flags;
271 UIndex used; // Number of elements (for series).
272 union
273 {
276 char* c;
277 uint8_t* b;
278 int16_t* i16;
279 uint16_t* u16;
280 int32_t* i;
281 int32_t* i32;
282 uint32_t* u32;
283 double* d;
284 float* f;
285 void* v;
287};
288
289
290/* Buffer flags */
291#define UR_STRING_ENC_UP 0x01
292#define UR_STATIC 0x80
293
294
295typedef struct UEnv UEnv;
296typedef struct UThread UThread;
297typedef struct UDatatype UDatatype;
298
299
306
307
309{
311 UBuffer stack;
314 UBuffer blocksSeen; // Prevent recursion in block functions.
315 UCell tmpWordCell;
316 uint32_t flags;
317 uint32_t _pad;
320 UBuffer* sharedStoreBuf;
321 UEnv* env;
323 const UCell* (*wordCell)( UThread*, const UCell* );
324 UCell* (*wordCellM)( UThread*, const UCell* );
325};
326
327#define UR_MAIN_CONTEXT 1
328
329/* Thread flags */
330
331#define UR_TFLAG_INITIAL 1
332#define UR_TFLAG_FIBRE 2
333
334
335typedef struct
336{
337 const UBuffer* buf;
340}
342
343typedef struct
344{
345 UBuffer* buf;
346 UIndex it;
347 UIndex end;
348}
349USeriesIterM;
350
351typedef struct
352{
353 const UBuffer* buf;
354 const uint8_t* it;
355 const uint8_t* end;
356}
357UBinaryIter;
358
359typedef struct
360{
361 UBuffer* buf;
362 uint8_t* it;
363 uint8_t* end;
364}
365UBinaryIterM;
366
367
368typedef struct
369{
370 const UBuffer* buf;
371 const UCell* it;
372 const UCell* end;
373}
374UBlockIter;
375
376typedef struct
377{
378 UBuffer* buf;
379 UCell* it;
380 UCell* end;
381}
382UBlockIterM;
383
384
385typedef struct
386{
387 const UCell* it;
388 const UCell* end;
389}
391
392
393typedef struct
394{
395 UCell* it;
396 UCell* end;
397}
398UBlockItM;
399
400
401typedef struct
402{
403 const UBuffer* ctx;
406 UAtom self;
407}
409
410
411enum UrlanCompareTest
412{
413 UR_COMPARE_SAME,
414 UR_COMPARE_EQUAL,
415 UR_COMPARE_EQUAL_CASE,
416 UR_COMPARE_ORDER,
417 UR_COMPARE_ORDER_CASE,
418};
419
420enum UrlanOperator
421{
422 UR_OP_ADD,
423 UR_OP_SUB,
424 UR_OP_MUL,
425 UR_OP_DIV,
426 UR_OP_MOD,
427 UR_OP_AND,
428 UR_OP_OR,
429 UR_OP_XOR
430};
431
437
439{
440 const char* name;
441
442 int (*make) ( UThread*, const UCell* from, UCell* res );
443 int (*convert) ( UThread*, const UCell* from, UCell* res );
444 void (*copy) ( UThread*, const UCell* from, UCell* res );
445 int (*compare) ( UThread*, const UCell* a, const UCell* b, int test );
446 int (*operate) ( UThread*, const UCell*, const UCell*, UCell* res, int );
447 const UCell*
448 (*select) ( UThread*, const UCell*, const UCell* sel, UCell* tmp );
449 void (*toString) ( UThread*, const UCell* cell, UBuffer* str, int depth );
450 void (*toText) ( UThread*, const UCell* cell, UBuffer* str, int depth );
451
452 void (*recycle) ( UThread*, int phase );
453 void (*mark) ( UThread*, UCell* cell );
454 void (*destroy) ( UBuffer* buf );
455 void (*markBuf) ( UThread*, UBuffer* buf );
456 void (*toShared) ( UCell* cell );
457
458 void (*bind) ( UThread*, UCell* cell, const UBindTarget* bt );
459};
460
461
462enum UrlanFindOption
463{
464 UR_FIND_LAST = 1,
465 UR_FIND_CASE
466};
467
468typedef struct
469{
470 UDatatype dt;
471 void (*pick) ( const UBuffer* buf, UIndex n, UCell* res );
472 void (*poke) ( UBuffer* buf, UIndex n, const UCell* val );
473 int (*append) ( UThread*, UBuffer* buf, const UCell* val );
474 int (*insert) ( UThread*, UBuffer* buf, UIndex index,
475 const UCell* val, UIndex part );
476 int (*change) ( UThread*, USeriesIterM* si, const UCell* val,
477 UIndex part );
478 void (*remove) ( UThread*, USeriesIterM* si, UIndex part );
479 void (*reverse) ( const USeriesIterM* si );
480 int (*find) ( UThread*, const USeriesIter* si, const UCell* val,
481 int opt );
482}
484
485
486typedef struct
487{
488 UAtom atom;
489 uint16_t index; // LIMIT: 65535 words per context.
490}
491UAtomEntry;
492
493
494typedef struct UEnvParameters UEnvParameters;
495
497{
499 void (*envInit)(UEnv*, const UEnvParameters*);
501 uint16_t dtCount;
502 uint16_t atomLimit;
503 uint32_t atomNamesSize;
504 uint32_t envSize;
505 uint32_t threadSize;
506 uint32_t user0;
507};
508
509
510#ifdef __cplusplus
511extern "C" {
512#endif
513
516void ur_freeEnv( UThread* );
517void ur_freezeEnv( UThread* );
518UThread* ur_makeThread( const UThread*, uint32_t flags );
521UAtom ur_intern( UThread*, const char* name, int len );
522UAtom ur_internAtom( UThread*, const char* it, const char* end );
523UAtom* ur_internAtoms( UThread*, const char* words, UAtom* atoms );
524const char* ur_atomCStr( UThread*, UAtom atom );
525void ur_atomsSort( UAtomEntry* entries, int low, int high );
526int ur_atomsSearch( const UAtomEntry* entries, int count, UAtom atom );
527UBuffer* ur_genBuffers( UThread*, int count, UIndex* index );
528UBuffer* ur_generate( UThread*, int count, UIndex* index, const uint8_t* );
531void ur_releaseBuffer( UThread*, UIndex hold );
532void ur_recycle( UThread* );
533int ur_markBuffer( UThread*, UIndex bufN );
534UCell* ur_push( UThread*, int type );
535UCell* ur_pushCell( UThread*, const UCell* );
536UStatus ur_error( UThread*, int errorType, const char* fmt, ... );
539void ur_traceError( UThread*, const UCell* errC, UIndex blkN,
540 const UCell* pos );
541void ur_appendTrace( UThread*, UIndex blkN, UIndex it );
542UIndex ur_tokenize( UThread*, const char* it, const char* end, UCell* res );
543UStatus ur_tokenizeB( UThread*, UIndex blkN, int inputEncoding,
544 const uint8_t* start, const uint8_t* end );
545UStatus ur_serialize( UThread*, UIndex blkN, UCell* res );
546UStatus ur_unserialize( UThread*, const uint8_t* start, const uint8_t* end,
547 UCell* res );
548void ur_toStr( UThread*, const UCell* cell, UBuffer* str, int depth );
549void ur_toText( UThread*, const UCell* cell, UBuffer* str );
550const UCell* ur_wordCell( UThread*, const UCell* cell );
551UCell* ur_wordCellM( UThread*, const UCell* cell );
552UStatus ur_setWord( UThread*, const UCell* wordCell, const UCell* src );
553const UBuffer* ur_bufferEnv( UThread*, UIndex n );
554const UBuffer* ur_bufferSeries( const UThread*, const UCell* cell );
555UBuffer* ur_bufferSeriesM( UThread*, const UCell* cell );
556void ur_initSeries( UCell*, int type, UIndex buf );
557void ur_seriesSlice( const UThread*, USeriesIter* si, const UCell* cell );
558UStatus ur_seriesSliceM( UThread*, USeriesIterM* si, const UCell* cell );
559const UBuffer* ur_blockIt( const UThread* ut, UBlockIt* bi,
560 const UCell* blkCell );
561void ur_bind( UThread*, UBuffer* blk, const UBuffer* ctx, int bindType );
562void ur_bindCells( UThread*, UCell* it, UCell* end, const UBindTarget* bt );
563void ur_bindCopy( UThread*, const UBuffer* ctx, UCell* it, UCell* end );
564void ur_unbindCells( UThread*, UCell* it, UCell* end, int deep );
565void ur_infuse( UThread*, UCell* it, UCell* end, const UBuffer* ctx );
566int ur_true( const UCell* cell );
567int ur_same( UThread*, const UCell* a, const UCell* b );
568int ur_equal( UThread*, const UCell* a, const UCell* b );
569int ur_equalCase( UThread*, const UCell* a, const UCell* b );
570int ur_compare( UThread*, const UCell* a, const UCell* b );
571int ur_compareCase( UThread*, const UCell* a, const UCell* b );
572
573void ur_makeDatatype( UCell* cell, int type );
574int ur_isDatatype( const UCell* cell, const UCell* datatype );
575void ur_datatypeAddType( UCell* cell, int type );
576
577int ur_charLowercase( int c );
578int ur_charUppercase( int c );
579
580UIndex ur_makeBinary( UThread*, int size );
581UBuffer* ur_makeBinaryCell( UThread*, int size, UCell* cell );
582void ur_binInit( UBuffer*, int size );
583void ur_binReserve( UBuffer*, int size );
584void ur_binExpand( UBuffer*, int index, int count );
585void ur_binErase( UBuffer*, int start, int count );
586void ur_binAppendData( UBuffer*, const uint8_t* data, int len );
587void ur_binAppendArray( UBuffer*, const USeriesIter* si );
588const char* ur_binAppendBase( UBuffer* buf, const char* it, const char* end,
589 enum UrlanBinaryEncoding enc );
590void ur_binFree( UBuffer* );
591void ur_binSlice( UThread*, UBinaryIter*, const UCell* cell );
592UStatus ur_binSliceM( UThread*, UBinaryIterM*, const UCell* cell );
593void ur_binToStr( UBuffer*, int encoding );
594
595UBuffer* ur_makeBitsetCell( UThread*, int bitCount, UCell* res );
596
597UIndex ur_makeString( UThread*, int enc, int size );
598UBuffer* ur_makeStringCell( UThread*, int enc, int size, UCell* cell );
599UIndex ur_makeStringLatin1( UThread*, const uint8_t* it, const uint8_t* end );
600UIndex ur_makeStringUtf8( UThread*, const uint8_t* it, const uint8_t* end );
601void ur_strInit( UBuffer*, int enc, int size );
602void ur_strInitUtf8( UBuffer*, const uint8_t* it, const uint8_t* end );
603void ur_strAppendCStr( UBuffer*, const char* );
604void ur_strAppendChar( UBuffer*, int );
605void ur_strAppendInt( UBuffer*, int32_t );
606void ur_strAppendInt64( UBuffer*, int64_t );
607void ur_strAppendHex( UBuffer*, uint32_t n, uint32_t hi );
608void ur_strAppendDouble( UBuffer*, double );
609void ur_strAppendFloat( UBuffer*, float );
610void ur_strAppendIndent( UBuffer*, int depth );
611void ur_strAppend( UBuffer*, const UBuffer* strB, UIndex itB, UIndex endB );
612void ur_strAppendBinary( UBuffer*, const uint8_t* it, const uint8_t* end,
613 enum UrlanBinaryEncoding enc );
614void ur_strTermNull( UBuffer* );
615int ur_strIsAscii( const UBuffer* );
616void ur_strFlatten( UBuffer* );
617void ur_strLowercase( UBuffer* str, UIndex start, UIndex send );
618void ur_strUppercase( UBuffer* str, UIndex start, UIndex send );
619UIndex ur_strFindChar( const UBuffer*, UIndex, UIndex, int ch, int opt );
620UIndex ur_strFindChars( const UBuffer*, UIndex start, UIndex end,
621 const uint8_t* charSet, int len );
622UIndex ur_strFindCharsRev( const UBuffer*, UIndex start, UIndex end,
623 const uint8_t* charSet, int len );
624UIndex ur_strFind( const USeriesIter*, const USeriesIter*, int matchCase );
625UIndex ur_strFindRev( const USeriesIter*, const USeriesIter*, int matchCase );
626UIndex ur_strMatch( const USeriesIter*, const USeriesIter*, int matchCase );
627int ur_strChar( const UBuffer*, UIndex pos );
628char* ur_cstring( const UBuffer*, UBuffer* bin, UIndex start, UIndex end );
629#define ur_strFree ur_arrFree
630#define ur_strIsUcs2(buf) ((buf)->form == UR_ENC_UCS2)
631
632UIndex ur_makeBlock( UThread*, int size );
633UBuffer* ur_makeBlockCell( UThread*, int type, int size, UCell* cell );
635void ur_blkInit( UBuffer*, int type, int size );
636UCell* ur_blkAppendNew( UBuffer*, int type );
637void ur_blkAppendCells( UBuffer*, const UCell* cells, int count );
638void ur_blkInsert( UBuffer*, UIndex it, const UCell* cells, int count );
639void ur_blkPush( UBuffer*, const UCell* cell );
641void ur_blkSlice( UThread*, UBlockIter*, const UCell* cell );
642UStatus ur_blkSliceM( UThread*, UBlockIterM*, const UCell* cell );
643void ur_blkCollectType( UThread*, const UCell* blkCell,
644 uint32_t typeMask, UBuffer* dest, int unique );
645#define ur_blkFree ur_arrFree
646
647UBuffer* ur_makePathCell( UThread*, const UCell* nodes, int size, UCell* cell );
648//int ur_pathResolve( UThread*, UBlockIt* pi, UCell* tmp, UCell** lastCell );
649//int ur_pathCell( UThread*, const UCell* pc, UCell* res );
650UStatus ur_setPath( UThread*, const UCell* path, const UCell* src );
651
652UIndex ur_makeContext( UThread*, int size );
653UBuffer* ur_makeContextCell( UThread*, int size, UCell* cell );
654UBuffer* ur_ctxClone( UThread*, const UBuffer* src, UCell* cell );
655UBuffer* ur_ctxMirror( UThread*, const UBuffer* src, UCell* cell );
656void ur_ctxInit( UBuffer*, int size );
657void ur_ctxReserve( UBuffer*, int size );
658void ur_ctxFree( UBuffer* );
660void ur_ctxSetWords( UBuffer*, const UCell* it, const UCell* end );
661int ur_ctxAppendWord( UBuffer*, UAtom atom );
662int ur_ctxAddWordI( UBuffer*, UAtom atom );
663UCell* ur_ctxAddWord( UBuffer*, UAtom atom );
664void ur_ctxWordAtoms( const UBuffer*, UAtom* atoms );
665int ur_ctxLookup( const UBuffer*, UAtom atom );
666const UBuffer* ur_sortedContext( UThread*, const UCell* );
667#define ur_ctxLookupNoSort ur_ctxLookup
668#define ur_ctxCell(c,n) ((c)->ptr.cell + (n))
669
670UIndex ur_makeVector( UThread*, enum UrlanVectorType, int size );
671UBuffer* ur_makeVectorCell( UThread*, enum UrlanVectorType, int size, UCell* );
672
673void ur_arrInit( UBuffer*, int size, int count );
674void ur_arrReserve( UBuffer*, int count );
675void ur_arrExpand( UBuffer*, int index, int count );
676void ur_arrErase( UBuffer*, int start, int count );
677void ur_arrFree( UBuffer* );
678void ur_arrAppendInt32( UBuffer*, int32_t );
679void ur_arrAppendFloat( UBuffer*, float );
680
681#ifdef __cplusplus
682}
683#endif
684
685
686#define ur_ptr(T,buf) ((T*) (buf)->ptr.v)
687#define ur_avail(buf) (buf)->ptr.i32[-1]
688#define ur_testAvail(buf) (buf->ptr.v ? ur_avail(buf) : 0)
689
690#define ur_arrExpand1(T,buf,elem) \
691 ur_arrReserve(buf, buf->used + 1); \
692 elem = ur_ptr(T,buf) + buf->used; \
693 ++buf->used
694
695#define ur_type(c) (c)->id.type
696#ifdef __BIG_ENDIAN__
697#define ur_setId(c,t) *((uint32_t*) (c)) = (t) << 24
698#define ur_initCoord(c,n) *((uint32_t*) (c)) = UT_COORD << 24 | (n)
699#define ur_bufHeader(type,es,form,fl) (type<<24 | es<<16 | form<<8 | fl)
700#else
701#define ur_setId(c,t) *((uint32_t*) (c)) = t
702#define ur_initCoord(c,n) *((uint32_t*) (c)) = UT_COORD | (n) << 16
703#define ur_bufHeader(type,es,form,fl) (fl<<24 | form<<16 | es<<8 | type)
704#endif
705#define ur_setFlags(c,m) (c)->id.flags |= m
706#define ur_clrFlags(c,m) (c)->id.flags &= ~(m)
707#define ur_flags(c,m) ((c)->id.flags & m)
708#define ur_is(c,t) ((c)->id.type == (t))
709
710#define ur_atom(c) (c)->word.atom
711#define ur_datatype(c) (c)->datatype.n
712#define ur_logic(c) (c)->id.ext
713#define ur_char(c) (c)->number.eb.i64
714#define ur_int(c) (c)->number.eb.i64
715#define ur_double(c) (c)->number.eb.d
716
717#define ur_isWordType(t) ((t) >= UT_WORD && (t) <= UT_OPTION)
718#define ur_binding(c) (c)->word.binding
719#define ur_setBinding(c,bindType) (c)->word.binding = bindType
720
721#define ur_isBlockType(t) ((t) == UT_BLOCK || (t) == UT_PAREN)
722#define ur_isPathType(t) ((t) >= UT_PATH && (t) <= UT_SETPATH)
723#define ur_isStringType(t) ((t) == UT_STRING || (t) == UT_FILE)
724
725#define ur_isSeriesType(t) ((t) >= UT_BINARY && (t) < UT_PATH)
726#define ur_isShared(n) (n < 0)
727#define ur_isSliced(c) ((c)->series.end > -1)
728
729#define ur_setWordUnbound(c,atm) \
730 (c)->word.atom = atm; \
731 (c)->word.ctx = UR_INVALID_BUF
732
733// (c)->word.index = -1
734
735#define ur_setSeries(c,bn,sit) \
736 (c)->series.buf = bn; \
737 (c)->series.it = sit; \
738 (c)->series.end = -1
739
740#define ur_setSlice(c,bn,sit,send) \
741 (c)->series.buf = bn; \
742 (c)->series.it = sit; \
743 (c)->series.end = send
744
745#define ur_stackTop(ut) (ut->stack.ptr.cell + ut->stack.used - 1)
746#define ur_exception(ut) ut->stack.ptr.cell
747#define ur_pop(ut) --(ut)->stack.used
748#define ur_hold(n) ur_holdBuffer(ut,n)
749#define ur_release(h) ur_releaseBuffer(ut,h)
750#define ur_buffer(n) (ut->dataStore.ptr.buf + (n))
751#define ur_bufferE(n) ur_bufferEnv(ut,n)
752#define ur_bufferSer(c) ur_bufferSeries(ut,c)
753#define ur_bufferSerM(c) ur_bufferSeriesM(ut,c)
754
755#define ur_bufferInit(b,head,count,data) \
756 *((uint32_t*) b) = head; \
757 b->used = count; \
758 b->ptr.v = data
759
760#define ur_foreach(bi) for(; bi.it != bi.end; ++bi.it)
761
762#define ur_wordCStr(c) ur_atomCStr(ut, ur_atom(c))
763
764#define ur_cstr(strC,bin) \
765 ur_cstring(ur_bufferSer(strC), bin, strC->series.it, strC->series.end)
766
767
768#endif /*EOF*/
void ur_binToStr(UBuffer *, int encoding)
Convert binary buffer to string buffer.
Definition binary.c:486
const char * ur_binAppendBase(UBuffer *buf, const char *it, const char *end, enum UrlanBinaryEncoding enc)
Append encoded ASCII string to binary buffer.
Definition binary.c:282
UStatus ur_binSliceM(UThread *, UBinaryIterM *, const UCell *cell)
Set UBinaryIterM to binary slice.
Definition binary.c:456
void ur_binErase(UBuffer *, int start, int count)
Remove bytes from the binary.
Definition binary.c:171
void ur_binAppendData(UBuffer *, const uint8_t *data, int len)
Append data to binary buffer.
Definition binary.c:213
UBuffer * ur_makeBinaryCell(UThread *, int size, UCell *cell)
Generate a single binary and set cell to reference it.
Definition binary.c:74
void ur_binReserve(UBuffer *, int size)
Allocates enough memory to hold size bytes.
Definition binary.c:138
void ur_binInit(UBuffer *, int size)
Initialize buffer to type UT_BINARY.
Definition binary.c:93
void ur_binFree(UBuffer *)
Free binary data.
Definition binary.c:120
void ur_binSlice(UThread *, UBinaryIter *, const UCell *cell)
Set UBinaryIter to binary slice.
Definition binary.c:423
void ur_binAppendArray(UBuffer *, const USeriesIter *si)
Append array slice to binary buffer.
Definition binary.c:227
void ur_binExpand(UBuffer *, int index, int count)
Create space in the binary for count bytes starting at index.
Definition binary.c:194
UIndex ur_makeBinary(UThread *, int size)
Generate and initialize a single binary buffer.
Definition binary.c:56
UIndex ur_blkClone(UThread *, UIndex blkN)
Make deep copy of block.
Definition block.c:256
void ur_blkInsert(UBuffer *, UIndex it, const UCell *cells, int count)
Insert cells into block.
Definition block.c:143
void ur_blkInit(UBuffer *, int type, int size)
Initialize block buffer.
Definition block.c:96
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.
Definition block.c:297
UCell * ur_blkPop(UBuffer *)
Remove cell from end of block.
Definition block.c:166
void ur_blkPush(UBuffer *, const UCell *cell)
Copy cell to end of block.
Definition block.c:153
void ur_blkSlice(UThread *, UBlockIter *, const UCell *cell)
Set UBlockIter to block slice.
Definition block.c:189
UStatus ur_blkSliceM(UThread *, UBlockIterM *, const UCell *cell)
Set UBlockIterM to block slice.
Definition block.c:224
UCell * ur_blkAppendNew(UBuffer *, int type)
Add cell to end of block.
Definition block.c:109
UIndex ur_makeBlock(UThread *, int size)
Generate a single block of type UT_BLOCK.
Definition block.c:57
void ur_blkAppendCells(UBuffer *, const UCell *cells, int count)
Append cells to block.
Definition block.c:125
UBuffer * ur_makeBlockCell(UThread *, int type, int size, UCell *cell)
Generate a single block and set cell to reference it.
Definition block.c:76
UBuffer * ur_ctxMirror(UThread *, const UBuffer *src, UCell *cell)
Create a shallow copy of a context and set cell to reference the new context.
Definition context.c:257
void ur_infuse(UThread *, UCell *it, UCell *end, const UBuffer *ctx)
Replace words in cells with their values from a context.
Definition context.c:837
UBuffer * ur_ctxClone(UThread *, const UBuffer *src, UCell *cell)
Clone a new context and set cell to reference it.
Definition context.c:220
UCell * ur_ctxAddWord(UBuffer *, UAtom atom)
Similar to ur_ctxAddWordI(), but safely returns the cell pointer.
Definition context.c:437
int ur_ctxAddWordI(UBuffer *, UAtom atom)
Add word to context if it does not already exist.
Definition context.c:420
void ur_ctxFree(UBuffer *)
Free context data.
Definition context.c:316
int ur_ctxLookup(const UBuffer *, UAtom atom)
Find word in context by atom.
Definition context.c:579
void ur_bindCells(UThread *, UCell *it, UCell *end, const UBindTarget *bt)
Bind an array of cells to a target.
Definition context.c:614
int ur_atomsSearch(const UAtomEntry *entries, int count, UAtom atom)
Find an atom in a UAtomEntry table using a binary search.
Definition context.c:355
void ur_atomsSort(UAtomEntry *entries, int low, int high)
Sort UAtomEntry table in ascending atom value order.
Definition context.c:459
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.
Definition context.c:283
UBuffer * ur_makeContextCell(UThread *, int size, UCell *cell)
Generate a single context and set cell to reference it.
Definition context.c:111
UBuffer * ur_ctxSort(UBuffer *)
Sort the internal context search table so ur_ctxLookup() is faster.
Definition context.c:510
int ur_ctxAppendWord(UBuffer *, UAtom atom)
Append word to context.
Definition context.c:390
void ur_bindCopy(UThread *, const UBuffer *ctx, UCell *it, UCell *end)
Recursively bind blocks to the bindings found in a context.
Definition context.c:732
void ur_ctxWordAtoms(const UBuffer *, UAtom *atoms)
Get word atoms in order.
Definition context.c:334
UIndex ur_makeContext(UThread *, int size)
Generate and initialize a single context.
Definition context.c:93
void ur_unbindCells(UThread *, UCell *it, UCell *end, int deep)
Unbind all words in an array of cells.
Definition context.c:790
void ur_bind(UThread *, UBuffer *blk, const UBuffer *ctx, int bindType)
Bind block to context.
Definition context.c:690
const UBuffer * ur_sortedContext(UThread *, const UCell *)
Get context and make sure it is fully sorted for minimal ur_ctxLookup() time.
Definition context.c:547
void ur_ctxReserve(UBuffer *, int size)
Allocates enough memory to hold size words.
Definition context.c:133
void ur_ctxInit(UBuffer *, int size)
Initialize context buffer.
Definition context.c:299
UStatus ur_setPath(UThread *, const UCell *path, const UCell *src)
Set path.
Definition path.c:361
UBuffer * ur_makePathCell(UThread *, const UCell *nodes, int size, UCell *cell)
Initialize path cell and generate block if needed.
Definition path.c:65
UBuffer * ur_makeStringCell(UThread *, int enc, int size, UCell *cell)
Generate a single string and set cell to reference it.
Definition string.c:104
int ur_strChar(const UBuffer *, UIndex pos)
Return the character at a given position.
Definition string.c:1659
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.
Definition string.c:1388
void ur_strAppendBinary(UBuffer *, const uint8_t *it, const uint8_t *end, enum UrlanBinaryEncoding enc)
Append binary data as text of the specified encoding.
Definition string.c:998
int ur_strIsAscii(const UBuffer *)
Test if all characters are ASCII.
Definition string.c:1066
void ur_strAppendChar(UBuffer *, int)
Append a single UCS2 character to a string.
Definition string.c:611
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.
Definition string.c:1353
void ur_strAppendIndent(UBuffer *, int depth)
Append tabs to a string.
Definition string.c:851
UIndex ur_makeString(UThread *, int enc, int size)
Generate and initialize a single string buffer.
Definition string.c:85
UIndex ur_strFindRev(const USeriesIter *, const USeriesIter *, int matchCase)
Find last string in another string or binary series.
Definition string.c:1531
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.
Definition string.c:415
void ur_strAppendHex(UBuffer *, uint32_t n, uint32_t hi)
Append a hexidecimal integer to a string.
Definition string.c:765
UIndex ur_strMatch(const USeriesIter *, const USeriesIter *, int matchCase)
Compare characters in two string or binary series.
Definition string.c:1584
void ur_strTermNull(UBuffer *)
Terminate with null character so buffer can be used as a C string.
Definition string.c:1049
void ur_strInitUtf8(UBuffer *, const uint8_t *it, const uint8_t *end)
Initialize a single string buffer from memory holding a UTF-8 string.
Definition string.c:345
void ur_strAppendInt(UBuffer *, int32_t)
Append an integer to a string.
Definition string.c:706
void ur_strInit(UBuffer *, int enc, int size)
Initialize buffer to type UT_STRING.
Definition string.c:430
UIndex ur_strFindChar(const UBuffer *, UIndex, UIndex, int ch, int opt)
Find the first instance of a character in a string.
Definition string.c:1292
char * ur_cstring(const UBuffer *, UBuffer *bin, UIndex start, UIndex end)
Make null terminated UTF-8 string in binary buffer.
Definition string.c:1684
void ur_strAppend(UBuffer *, const UBuffer *strB, UIndex itB, UIndex endB)
Append another string buffer to this string.
Definition string.c:899
void ur_strLowercase(UBuffer *str, UIndex start, UIndex send)
Convert characters of string slice to lowercase.
Definition string.c:1178
void ur_strAppendDouble(UBuffer *, double)
Append a double to a string.
Definition string.c:787
UIndex ur_strFind(const USeriesIter *, const USeriesIter *, int matchCase)
Find string in another string or binary series.
Definition string.c:1451
void ur_strAppendFloat(UBuffer *, float)
Append a float to a string.
Definition string.c:813
void ur_strAppendInt64(UBuffer *, int64_t)
Append an 64-bit integer to a string.
Definition string.c:725
void ur_strAppendCStr(UBuffer *, const char *)
Append a null-terminated UTF-8 string to a string buffer.
Definition string.c:641
void ur_strFlatten(UBuffer *)
Convert a UTF-8 or UCS-2 string buffer to Latin-1 if possible.
Definition string.c:1104
void ur_strUppercase(UBuffer *str, UIndex start, UIndex send)
Convert characters of string slice to uppercase.
Definition string.c:1216
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.
Definition string.c:133
void ur_seriesSlice(const UThread *, USeriesIter *si, const UCell *cell)
Set USeriesIter to series slice.
Definition env.c:1338
void ur_releaseBuffer(UThread *, UIndex hold)
Enables garbage collection of dataStore buffer which was held by ur_holdBuffer().
Definition env.c:877
void ur_freeEnv(UThread *)
Free environment and the initial thread.
Definition env.c:480
@ UT_TYPEMASK
Used in UCellDatatype to declare a multi-type datatype!.
Definition urlan.h:73
const char * ur_atomCStr(UThread *, UAtom atom)
Get name of atom.
Definition atoms.c:47
const UBuffer * ur_bufferEnv(UThread *, UIndex n)
Get buffer from either the thread dataStore or environment sharedStore.
Definition env.c:1258
UIndex ur_tokenize(UThread *, const char *it, const char *end, UCell *res)
Convert a UTF-8 data string into a block.
Definition tokenize.c:1197
UIndex it
Start position.
Definition urlan.h:338
UStatus ur_error(UThread *, int errorType, const char *fmt,...)
Create error! exception.
Definition env.c:964
UCell * ur_push(UThread *, int type)
Set id of cell on top of stack and increment stack.used.
Definition env.c:906
const UCell * ur_wordCell(UThread *, const UCell *cell)
Get word value for read-only operations.
Definition env.c:1132
void ur_freezeEnv(UThread *)
Move the startup thread dataStore to the shared environment.
Definition env.c:517
UAtom ur_intern(UThread *, const char *name, int len)
Add a single atom to the shared environment.
Definition env.c:596
UBuffer * ur_bufferSeriesM(UThread *, const UCell *cell)
Get modifiable series buffer.
Definition env.c:1298
const UBuffer * ur_bufferSeries(const UThread *, const UCell *cell)
Get series buffer.
Definition env.c:1282
UAtom ur_internAtom(UThread *, const char *it, const char *end)
Add a single atom to the shared environment.
Definition env.c:612
UBuffer * ur_envContext(UThread *)
Get shared global context.
Definition env.c:945
const UCell * end
End position.
Definition urlan.h:388
UStatus ur_setWord(UThread *, const UCell *wordCell, const UCell *src)
Set word.
Definition env.c:1225
int ur_same(UThread *, const UCell *a, const UCell *b)
Definition env.c:1041
void ur_toText(UThread *, const UCell *cell, UBuffer *str)
Append textual representation of cell to a string.
Definition env.c:1118
UStatus ur_seriesSliceM(UThread *, USeriesIterM *si, const UCell *cell)
Set USeriesIterM to modifiable series slice.
Definition env.c:1356
UStatus ur_tokenizeB(UThread *, UIndex blkN, int inputEncoding, const uint8_t *start, const uint8_t *end)
Parse UTF-8 or Latin1 data into block.
Definition tokenize.c:654
UIndex end
End position.
Definition urlan.h:339
const UCell * it
Start position.
Definition urlan.h:387
UBuffer * ur_threadContext(UThread *)
Get thread global context.
Definition env.c:934
UThread * ur_makeEnv(const UEnvParameters *)
Allocate UEnv and initial UThread.
Definition env.c:332
@ UR_THROW
Returned to indicate an evaluation exception occured.
Definition urlan.h:117
@ UR_OK
Returned to indicate successful evaluation/operation.
Definition urlan.h:118
int ur_destroyThread(UThread *)
Free memory used by UThread.
Definition env.c:214
UBuffer * ur_generate(UThread *, int count, UIndex *index, const uint8_t *)
Generate and initialize buffers of given types.
Definition env.c:771
int ur_true(const UCell *cell)
Check if a value is "true".
Definition env.c:1029
const UBuffer * ur_blockIt(const UThread *ut, UBlockIt *bi, const UCell *blkCell)
Set UBlockIt to the start and end of a block slice.
Definition env.c:1388
int ur_equal(UThread *, const UCell *a, const UCell *b)
Definition env.c:1053
@ UR_THREAD_FREEZE
The thread dataStore is being moved to the shared environment.
Definition urlan.h:304
@ UR_THREAD_INIT
The new thread must be initialized.
Definition urlan.h:302
@ UR_THREAD_FREE
The thread is being freed.
Definition urlan.h:303
const UBuffer * buf
Buffer pointer.
Definition urlan.h:337
UAtom * ur_internAtoms(UThread *, const char *words, UAtom *atoms)
Add atoms to the shared environment.
Definition env.c:645
int ur_datatypeCount(UThread *)
Get number of datatypes installed in the environment.
Definition env.c:580
void ur_appendTrace(UThread *, UIndex blkN, UIndex it)
Append block position to the current exception error! trace.
Definition env.c:1012
void ur_destroyBuffer(UThread *, UBuffer *)
Destroy buffer in dataStore.
Definition env.c:825
int ur_compare(UThread *, const UCell *a, const UCell *b)
Definition env.c:1079
int ur_equalCase(UThread *, const UCell *a, const UCell *b)
Case-sensitive equality test.
Definition env.c:1066
int ur_compareCase(UThread *, const UCell *a, const UCell *b)
Case-sensitive ordering comparison.
Definition env.c:1093
UIndex ur_holdBuffer(UThread *, UIndex bufN)
Keeps buffer in thread dataStore from being garbage collected by ur_recycle().
Definition env.c:854
UBuffer * ur_genBuffers(UThread *, int count, UIndex *index)
Generate new buffers in dataStore.
Definition env.c:685
UCell * ur_pushCell(UThread *, const UCell *)
Copy cell to top of stack and increment stack.used.
Definition env.c:920
UCell * ur_wordCellM(UThread *, const UCell *cell)
Get modifiable word value.
Definition env.c:1178
UEnvParameters * ur_envParam(UEnvParameters *par)
Initialize UEnvParameters structure to default values.
Definition env.c:288
void ur_toStr(UThread *, const UCell *cell, UBuffer *str, int depth)
Append data representation of cell to a string.
Definition env.c:1107
UThread * ur_makeThread(const UThread *, uint32_t flags)
Create a new thread.
Definition env.c:160
Holds information for binding functions.
Definition urlan.h:402
const UBuffer * ctx
Context buffer to lookup words in.
Definition urlan.h:403
UIndex ctxN
Words in the block which are found in the UBindTarget::ctx will have their UCell.word....
Definition urlan.h:404
int bindType
Binding type to make.
Definition urlan.h:405
Iterator for const UCell array.
Definition urlan.h:386
The UBuffer struct holds information about a resource, usually a chunk of memory.
Definition urlan.h:266
uint8_t * b
bytes
Definition urlan.h:277
uint8_t form
This can indicate a specific form of the data (such as a string encoding).
Definition urlan.h:269
void * v
Other.
Definition urlan.h:285
int32_t * i32
int32_t
Definition urlan.h:281
char * c
chars
Definition urlan.h:276
UBuffer * buf
Array of buffers.
Definition urlan.h:274
int32_t * i
int32_t
Definition urlan.h:280
uint32_t * u32
uint32_t
Definition urlan.h:282
UIndex used
This typically holds the number of elements in the buffer.
Definition urlan.h:271
uint16_t * u16
uint16_t
Definition urlan.h:279
int16_t * i16
int16_t
Definition urlan.h:278
float * f
floats
Definition urlan.h:284
uint8_t type
UrlanDataType identifier.
Definition urlan.h:267
uint8_t flags
Indicates special features of the buffer (UR_STATIC, UR_STRING_ENC_UP).
Definition urlan.h:270
UCell * cell
Array of cells.
Definition urlan.h:275
double * d
doubles
Definition urlan.h:283
union UBuffer::@312146223224040072236377336057316010374162171270 ptr
This typically holds a pointer to a chunk of memory.
uint8_t elemSize
This typically holds the byte size of each element.
Definition urlan.h:268
UCell structure for coord type.
Definition urlan.h:191
uint8_t type
UrlanDataType.
Definition urlan.h:192
int16_t n[UR_COORD_MAX]
Holds six, 16-bit integers.
Definition urlan.h:195
uint16_t len
Number of integers used in array n.
Definition urlan.h:194
uint8_t flags
Bit field for type-specific properties.
Definition urlan.h:193
UCell structure for datatype! type.
Definition urlan.h:164
uint8_t n
The UrlanDataType.
Definition urlan.h:167
uint32_t mask0
Low 32 bits of type mask.
Definition urlan.h:169
uint32_t mask1
Middle 32 bits of type mask.
Definition urlan.h:170
UCell structure for error! type.
Definition urlan.h:236
UIndex messageStr
Index of message string! buffer.
Definition urlan.h:240
uint16_t exType
The UrlanErrorType.
Definition urlan.h:239
UIndex traceBlk
Index of block! buffer where error occurred.
Definition urlan.h:241
Basic type identification.
Definition urlan.h:155
uint8_t type
UrlanDataType.
Definition urlan.h:156
uint16_t ext
Extra datatype specific field.
Definition urlan.h:158
uint8_t flags
Bit field for type-specific properties.
Definition urlan.h:157
UCell structure for number types.
Definition urlan.h:177
UCellId id
Type and flags.
Definition urlan.h:178
double d
Double for double!, date!, and time! type.
Definition urlan.h:182
int64_t i64
Integer for char! and int! types.
Definition urlan.h:181
UCell structure for series types.
Definition urlan.h:226
UIndex end
Slice end index.
Definition urlan.h:230
UIndex buf
Buffer id.
Definition urlan.h:228
UIndex it
Iterator index.
Definition urlan.h:229
UCellId id
Type and flags.
Definition urlan.h:227
UCell structure for vec3! type.
Definition urlan.h:201
float xyz[3]
The three float values.
Definition urlan.h:203
UCellId id
The standard UCell header.
Definition urlan.h:202
UCell structure for word types.
Definition urlan.h:212
uint16_t index
Normally the word index into a context.
Definition urlan.h:218
uint8_t flags
Bit field for type-specific properties.
Definition urlan.h:214
uint8_t binding
Specifies what UrlanWordBindings the UCellWord::ctx refers to.
Definition urlan.h:215
uint8_t type
UrlanDataType.
Definition urlan.h:213
UAtom atom
The name of the word.
Definition urlan.h:219
UIndex ctx
Normally the buffer id of a context.
Definition urlan.h:217
The UDatatype struct holds methods for a specific class of data.
Definition urlan.h:439
void(* mark)(UThread *, UCell *cell)
Responsible for marking any buffers referenced by the cell as used.
Definition urlan.h:453
void(* toString)(UThread *, const UCell *cell, UBuffer *str, int depth)
Convert cell to its string data representation.
Definition urlan.h:449
void(* toText)(UThread *, const UCell *cell, UBuffer *str, int depth)
Convert cell to its string textual representation.
Definition urlan.h:450
int(* compare)(UThread *, const UCell *a, const UCell *b, int test)
Perform a comparison between cells.
Definition urlan.h:445
void(* recycle)(UThread *, int phase)
Performs thread global garbage collection duties for the datatype.
Definition urlan.h:452
int(* convert)(UThread *, const UCell *from, UCell *res)
Convert data to a new instance of the type.
Definition urlan.h:443
int(* make)(UThread *, const UCell *from, UCell *res)
Make a new instance of the type.
Definition urlan.h:442
void(* destroy)(UBuffer *buf)
Free any memory or other resources the buffer uses.
Definition urlan.h:454
int(* operate)(UThread *, const UCell *, const UCell *, UCell *res, int)
Perform an operation on two cells.
Definition urlan.h:446
void(* toShared)(UCell *cell)
Change any buffer ids in the cell so that they reference the shared environment (negate the id).
Definition urlan.h:456
const char * name
ASCII name of type, ending with '!'.
Definition urlan.h:440
void(* bind)(UThread *, UCell *cell, const UBindTarget *bt)
Bind cell to target.
Definition urlan.h:458
void(* markBuf)(UThread *, UBuffer *buf)
Responsible for marking other buffers referenced by this buffer as used.
Definition urlan.h:455
void(* copy)(UThread *, const UCell *from, UCell *res)
Make a clone of an existing value.
Definition urlan.h:444
The UEnvParameters struct allows the user to override default buffer and structure sizes.
Definition urlan.h:497
const UDatatype ** dtTable
Pointers to user defined datatypes.
Definition urlan.h:498
uint16_t dtCount
Number of entries in dtTable.
Definition urlan.h:501
uint32_t envSize
Byte size of environment structure.
Definition urlan.h:504
uint32_t user0
A user defined parameter.
Definition urlan.h:506
uint16_t atomLimit
Maximum number of atoms.
Definition urlan.h:502
uint32_t threadSize
Byte size of thread structure.
Definition urlan.h:505
uint32_t atomNamesSize
Fixed byte size of atom name buffer.
Definition urlan.h:503
void(* threadMethod)(UThread *, enum UThreadMethod)
Function to handle initialization and cleanup of user data attached to threads.
Definition urlan.h:500
Iterator for const series of any type.
Definition urlan.h:336
The USeriesType struct holds extra methods for series datatypes.
Definition urlan.h:469
void(* reverse)(const USeriesIterM *si)
Reverse series elements.
Definition urlan.h:479
int(* insert)(UThread *, UBuffer *buf, UIndex index, const UCell *val, UIndex part)
Insert a value into the series.
Definition urlan.h:474
int(* find)(UThread *, const USeriesIter *si, const UCell *val, int opt)
Search for a value in the series.
Definition urlan.h:480
void(* remove)(UThread *, USeriesIterM *si, UIndex part)
Remove part of the series.
Definition urlan.h:478
int(* change)(UThread *, USeriesIterM *si, const UCell *val, UIndex part)
Change part of the series.
Definition urlan.h:476
int(* append)(UThread *, UBuffer *buf, const UCell *val)
Append a value to the series.
Definition urlan.h:473
void(* poke)(UBuffer *buf, UIndex n, const UCell *val)
Replace a single value in the series.
Definition urlan.h:472
void(* pick)(const UBuffer *buf, UIndex n, UCell *res)
Get a single value from the series.
Definition urlan.h:471
The UThread struct stores the data specific to a thread of execution.
Definition urlan.h:309
UBuffer holds
An array of buffer ids which will not be garbage collected.
Definition urlan.h:312
UBuffer gcBits
Used by ur_recycle() to denote buffers which are in use.
Definition urlan.h:313
const UDatatype ** types
Pointer to the datatypes.
Definition urlan.h:322
UBuffer dataStore
An array of buffers.
Definition urlan.h:310
UIndex freeBufList
Buffer index of an unused buffer.
Definition urlan.h:319
int32_t freeBufCount
Number of unused buffers.
Definition urlan.h:318
UEnv * env
Pointer to the shared environment.
Definition urlan.h:321
A cell holds a single value of a simple type or a reference (often to a UBuffer) for a complex type.
Definition urlan.h:248
UCellWord word
For word!, lit-word!, set-word!, get-word! types.
Definition urlan.h:251
UCellError error
For error! type.
Definition urlan.h:258
UCellVec3 vec3
For vec3! type.
Definition urlan.h:254
UCellNumber number
For int!, double! types.
Definition urlan.h:252
UCellCoord coord
For coord! type.
Definition urlan.h:253
UCellSeries series
For binary!, bitset!, string!, file!, block!, paren!, path! types.
Definition urlan.h:255
UCellSeries context
For context! type.
Definition urlan.h:256
UCellId id
Basic type identification.
Definition urlan.h:249
UCellSeries port
For port! type.
Definition urlan.h:257
UCellDatatype datatype
For datatype! type.
Definition urlan.h:250
UrlanDataType
Definition urlan.h:38
UBuffer * ur_makeVectorCell(UThread *, enum UrlanVectorType, int size, UCell *)
Generate a single vector and set cell to reference it.
Definition vector.c:86
UStatus ur_serialize(UThread *, UIndex blkN, UCell *res)
Serialize block.
Definition serialize.c:527
void ur_arrAppendInt32(UBuffer *, int32_t)
Append int32_t to array.
Definition array.c:180
UStatus
Definition urlan.h:116
void ur_arrExpand(UBuffer *, int index, int count)
Create space in the array for count elements starting at index.
Definition array.c:161
int ur_charUppercase(int c)
Convert UCS2 character to uppercase.
Definition ucs2_case.c:313
void ur_makeDatatype(UCell *cell, int type)
Initialize cell to be a UT_DATATYPE value of the given type.
Definition datatypes.c:389
int ur_charLowercase(int c)
Convert UCS2 character to lowercase.
Definition ucs2_case.c:293
UrlanErrorType
Definition urlan.h:124
@ UR_ERR_SCRIPT
General script evaluation error.
Definition urlan.h:126
@ UR_ERR_INTERNAL
Fatal internal problem.
Definition urlan.h:129
@ UR_ERR_ACCESS
Problem accessing external resources.
Definition urlan.h:128
@ UR_ERR_TYPE
Invalid argument/parameter datatype.
Definition urlan.h:125
@ UR_ERR_SYNTAX
Syntax error.
Definition urlan.h:127
UStatus ur_unserialize(UThread *, const uint8_t *start, const uint8_t *end, UCell *res)
Unserialize binary.
Definition serialize.c:1002
UThreadMethod
Definition urlan.h:301
void ur_datatypeAddType(UCell *cell, int type)
Add type to multi-type UT_DATATYPE cell.
Definition datatypes.c:414
void ur_arrFree(UBuffer *)
Free array data.
Definition array.c:79
UIndex ur_makeVector(UThread *, enum UrlanVectorType, int size)
Generate a single vector buffer.
Definition vector.c:66
int ur_isDatatype(const UCell *cell, const UCell *datatype)
Test if cell is of a certain datatype.
Definition datatypes.c:376
UrlanRecyclePhase
Definition urlan.h:433
@ UR_RECYCLE_MARK
Phase passed to UDatatype::recycle.
Definition urlan.h:434
@ UR_RECYCLE_SWEEP
Phase passed to UDatatype::recycle.
Definition urlan.h:435
void ur_arrInit(UBuffer *, int size, int count)
Initialize array buffer.
Definition array.c:47
int ur_markBuffer(UThread *, UIndex bufN)
Makes sure the buffer is marked as used.
Definition gc.c:326
UrlanWordBindings
Definition urlan.h:86
@ UR_BIND_THREAD
Bound to buffer in thread dataStore.
Definition urlan.h:88
@ UR_BIND_USER
Start of user defined bindings.
Definition urlan.h:93
@ UR_BIND_SECURE
As UR_BIND_THREAD but unbind if not in context.
Definition urlan.h:92
@ UR_BIND_UNBOUND
ur_setId() zeros binding so this is default.
Definition urlan.h:87
@ UR_BIND_ENV
Bound to buffer in shared env dataStore.
Definition urlan.h:89
@ UR_BIND_SELF
Evaluate to bound context rather than value.
Definition urlan.h:91
@ UR_BIND_STACK
Bound to thread stack.
Definition urlan.h:90
int32_t UIndex
This is an index into an array.
Definition urlan.h:150
void ur_arrAppendFloat(UBuffer *, float)
Append float to array.
Definition array.c:193
void ur_arrErase(UBuffer *, int start, int count)
Remove elements from the array.
Definition array.c:137
void ur_arrReserve(UBuffer *, int count)
Allocates enough memory to hold count elements.
Definition array.c:98
void ur_recycle(UThread *)
Perform garbage collection on thread dataStore.
Definition gc.c:156