21#define setBit(mem,n) (mem[(n)>>3] |= 1<<((n)&7))
24static void ur_binAppendInt(
UBuffer* bin, uint32_t n,
25 UAtom size,
int bigEndian )
75#define NATIVE_ENDIAN 1
77#define NATIVE_ENDIAN 0
91static int binary_construct2(
UThread* ut, BinConstructState* cs,
98 ur_binAppendInt(cs->bin, ur_int(cell), cs->size, cs->big);
105 n.f = ur_double(cell);
106 ur_binAppendInt(cs->bin, n.
i, UR_ATOM_U32, cs->big);
113 for (i = 0; i < len; ++i)
114 ur_binAppendInt(cs->bin, cell->
coord.
n[i], cs->size, cs->big);
119 if (cs->big == NATIVE_ENDIAN)
124 for (i = 0; i < 3; ++i) {
126 ur_binAppendInt(cs->bin, n.
i, UR_ATOM_U32, cs->big);
132 switch (ur_atom(cell))
137 cs->size = ur_atom(cell);
140 case UR_ATOM_BIG_ENDIAN:
144 case UR_ATOM_LITTLE_ENDIAN:
166 BinConstructState cs2 = *cs;
170 if (binary_construct2(ut, &cs2, b2.
it) ==
UR_THROW)
178 "Invalid construct binary! type (%s)",
187 BinConstructState cs;
191 cs.size = UR_ATOM_U32;
198 if (binary_construct2(ut, &cs, bi.
it) ==
UR_THROW)
209 if( ur_is(val, UT_WORD) )
213 if( ur_is(val, UT_NONE) )
216 return string_append( ut, str, val );
228#define SC_BIT_COUNT 256
240 if( (bi.
end - bi.
it) & 1 )
245 cset.
used = SC_BIT_COUNT / 8;
247 for( ; bi.
it != bi.
end; bi.
it += 2 )
249 if( ur_is(bi.
it, UT_CHAR) )
253 else if( ur_is(bi.
it, UT_STRING) )
264 if( ch >= 0 && ch < SC_BIT_COUNT )
265 setBit( cset.
ptr.
b, ch );
277 for( bi.
it = begin; bi.
it != bi.
end; bi.
it += 2 )
279 if( ur_is(bi.
it, UT_CHAR) )
281 if( ch == ur_int(bi.
it) )
287 if( sc_appendEval( ut, str, bi.
it + 1 ) !=
UR_OK )
292 else if( ur_is(bi.
it, UT_STRING) )
299 len = si.
end - si.
it;
312 if( bi.
it == bi.
end )
338 if( cmax && cmax < 256 )
341 bits = ur_makeBitsetCell( ut, cmax, res )->ptr.b;
352 if (prev >= 0 && range < 0) {
358 }
else if (range >= 0) {
364 for (; range <= c; ++range)
423CFUNC(cfunc_construct)
425 const UCell* plan = a1+1;
433 if( dt == UT_BINARY )
438 else if( dt == UT_BITSET )
440 if( ur_is(plan, UT_STRING) )
441 return bitset_construct( ut, plan, res );
442 if( ur_is(plan, UT_CHAR) )
443 return bitset_make( ut, plan, res );
451 if( ! ur_is(plan, UT_BLOCK) )
453 return binary_construct( ut, plan, res );
456 if( ! ur_is(plan, UT_BLOCK) )
459 return string_construct( ut,
#define CFUNC(name)
Macro to define C functions.
Definition boron.h:57
UStatus boron_badArg(UThread *, UIndex atom, int argN)
Throw a standardized error for an unexpected function argument.
Definition eval.c:696
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
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_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
UIndex ur_strMatch(const USeriesIter *, const USeriesIter *, int matchCase)
Compare characters in two string or binary series.
Definition string.c:1584
void ur_strAppend(UBuffer *, const UBuffer *strB, UIndex itB, UIndex endB)
Append another string buffer to this string.
Definition string.c:899
void ur_seriesSlice(const UThread *, USeriesIter *si, const UCell *cell)
Set USeriesIter to series slice.
Definition env.c:1338
#define ur_bufferSer(c)
Convenience macro for ur_bufferSeries().
Definition urlan.h:752
const char * ur_atomCStr(UThread *, UAtom atom)
Get name of atom.
Definition atoms.c:47
UIndex it
Start position.
Definition urlan.h:338
UStatus ur_error(UThread *, int errorType, const char *fmt,...)
Create error! exception.
Definition env.c:964
const UCell * ur_wordCell(UThread *, const UCell *cell)
Get word value for read-only operations.
Definition env.c:1132
const UCell * end
End position.
Definition urlan.h:388
UIndex end
End position.
Definition urlan.h:339
const UCell * it
Start position.
Definition urlan.h:387
@ 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
#define ur_foreach(bi)
Loop over all members of an iterator struct.
Definition urlan.h:760
#define ur_bufferSerM(c)
Convenience macro for ur_bufferSeriesM().
Definition urlan.h:753
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
const UBuffer * buf
Buffer pointer.
Definition urlan.h:337
#define ur_type(c)
Return UrlanDataType of cell.
Definition urlan.h:695
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
int32_t * i
int32_t
Definition urlan.h:280
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
union UBuffer::@312146223224040072236377336057316010374162171270 ptr
This typically holds a pointer to a chunk of memory.
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
float xyz[3]
The three float values.
Definition urlan.h:203
Iterator for const series of any type.
Definition urlan.h:336
The UThread struct stores the data specific to a thread of execution.
Definition urlan.h:309
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
UCellVec3 vec3
For vec3! type.
Definition urlan.h:254
UCellCoord coord
For coord! type.
Definition urlan.h:253
UStatus
Definition urlan.h:116
#define ur_datatype(c)
Access the UrlanDataType that a UCellDatatype represents.
Definition urlan.h:711
@ UR_ERR_TYPE
Invalid argument/parameter datatype.
Definition urlan.h:125
int32_t UIndex
This is an index into an array.
Definition urlan.h:150